// DEV / JSON-BEAUTIFY

JSON 格式化JSON Formatter

格式化、压缩与校验 JSON,实时提示语法错误位置。Format, minify and validate JSON with instant syntax error hints.

结果Result

过滤表达式在本地页面执行,不会上传。结果可切成树视图,点三角折叠节点。快捷键:Alt+F 重新格式化,Alt+C 压缩复制,Alt+\\ 转义复制。粘贴 JSON 或 URL 参数会自动转成格式化 JSON。Filter expressions run locally in this page. Switch the result to tree view and click the arrow to collapse a node. Shortcuts: Alt+F reformat, Alt+C copy minified, Alt+\\ copy escaped. Pasting JSON or URL params converts it to formatted JSON.

常见问题FAQ

JSON 格式化工具支持哪些格式?Which JSON variants does the formatter accept?

支持标准 JSON,以及带注释和尾逗号的 JSONC(常见于 VS Code 配置文件)。粘贴后会自动识别,也可以用“去除注释”按钮手动清理。Standard JSON and JSONC with comments and trailing commas, which is common in VS Code settings. Pasting is auto-detected, and the strip comments button cleans up files manually.

结果可以折叠吗?Can the result be collapsed?

可以。结果区支持树视图,点击节点前的三角即可折叠;也可以用“全部展开”和“全部折叠”一次性处理,默认只展开两层,避免大文件一屏放不下。Yes. The result has a tree view where clicking the arrow collapses a node, and expand all or collapse all handles everything at once. Two levels are expanded by default so large files stay readable.

大文件会不会卡?Will large files slow the page down?

单个节点一次最多渲染 100 个子项,超出部分按需加载,因此百万字符级别的 JSON 也能正常浏览。Each node renders at most 100 children at a time and loads the rest on demand, so JSON with millions of characters still scrolls smoothly.

能把 JSON 转成 TypeScript 接口吗?Can JSON be converted to TypeScript interfaces?

可以。“转 TypeScript”会根据 JSON 结构生成嵌套的 interface,缺失的字段标记为可选,混合类型用联合类型表示。Yes. The to TypeScript button generates nested interfaces from the JSON structure, marks missing fields as optional and represents mixed types with unions.

同类工具Related tools

所有计算都在你的浏览器本地完成,输入内容不会上传到任何服务器。Everything runs locally in your browser. Nothing you type is ever uploaded to a server.