JSON 美化与压缩 - 免费格式化和校验 JSON

粘贴、校验并美化 JSON,可选 2 / 4 / 8 个空格缩进,或压缩为单行。拖入 .json 文件或直接粘贴,然后复制或下载。

在此粘贴你的 JSON……

或拖入 .json 文件

文件在处理后自动删除通过 HTTPS 安全处理

Frequently Asked Questions

将你的 JSON 粘贴到输入面板——它会被即时解析,并以 2、4 或 8 个空格的缩进重新排版。如果 JSON 无效,原生解析器会给出错误所在的精确行号和列号。一切都在你的浏览器中运行,因此无需 API 密钥、没有速率限制,你的数据也绝不会离开设备。使用「美化」获得可读的缩进输出,或使用「压缩」折叠为单行以便通过网络传输。

usage

美化会添加换行和缩进,让 JSON 在调试时便于人工阅读和审查。压缩会去除每一个空格、制表符和换行符,生成尽可能小的文件体积——适用于 API 请求、嵌入源代码的配置以及减小打包体积。我们的工具一键即可在两种模式间切换。

features

校验由浏览器原生的 JSON.parse 驱动,这与每个 JavaScript 运行时所用的解析器完全相同。报错会精确指出出错的标记及其所在位置,通常能直接定位到缺失的逗号、不匹配的括号、多余的尾随逗号或未加引号的键名。修正高亮标出的位置后,输出面板会随你的输入实时更新。

technical

不会。JSON 美化工具 100% 在你的浏览器客户端运行——没有服务器往返、没有日志记录、没有缓存。因此,对于包含个人数据的 API 响应、内部配置或你绝不会粘贴到托管工具中的生产密钥等敏感数据,使用它都很安全。

privacy

可以。将任意 .json 文件拖到输入面板上,它就会直接读入编辑器。只要你的浏览器能将其保存在内存中,大文件(数兆字节的 API 转储、导出的配置、日志文件)都能处理——通常数十兆字节都没有问题。

usage

不支持,该工具严格遵循 RFC 8259 标准 JSON,因为这正是 JSON.parse 所接受的。注释、尾随逗号、单引号和未加引号的键都会被标记为无效。如果你需要 JSON5 或 JSONC 支持,请先去除非标准语法,再用 Pixoate 进行格式化。

features

格式化后,点击「复制」一键将结果放入剪贴板,或点击「下载」保存为 output.json(压缩模式下为 output.min.json)。输出会保留 UTF-8 编码,因此表情符号和非拉丁字符均完好无损。

tips

完全免费,无需注册账户。没有使用次数限制、没有水印、输出结果中没有广告,也没有付费档位。该工具与我们的 PDF 和图片实用工具一同提供,是面向开发者与创作者的免费工具套件的一部分。

pricing

它会依据 RFC 8259 标准校验你的 JSON 语法是否正确——解析文档并精确定位任何错误所在的行和列——但它不会对照 JSON Schema 进行检查(必填字段、值类型、取值范围)。用于即时语法检查和格式化时它非常理想;若需要 schema 一致性校验,则需使用专门的 JSON Schema 验证器。

technical

2 个空格是最常见的默认设置 — 它与 Prettier 及大多数风格指南一致,能防止深层嵌套的对象向右偏移太远。4 个空格更适合层级较浅的配置文件,而 8 个空格主要用于打印或演示。这三种缩进生成的都是完全相同、有效的 JSON,所以选你团队的 linter 所要求的那种即可,然后复制或下载结果。

tips

是的 — 除了这款 JSON 格式化工具,我们还有一个 HTML 美化工具,可对 HTML 进行美化和压缩,同属这套免费的浏览器内开发者工具集。专门针对 JSON,本页可处理美化、压缩和语法校验;其他语言请切换到对应的格式化工具。

features

Tree mode renders your parsed JSON as an interactive, collapsible tree instead of a flat text block, so you can expand or collapse nested objects and arrays to explore a large API response without scrolling through indentation. Prettify still gives you copyable, downloadable formatted text; switch to Tree when you just need to inspect structure, then back to Prettify or Minify when you need the actual output file.

features

Use Tree mode first to explore a big nested payload — expand only the branches you care about instead of scrolling a wall of indented text. Once you've confirmed the shape is correct, switch to Minify to produce the compact single-line JSON you actually paste into a request body or config file; both modes read the same pasted input, so switching between them is instant.

tips

Click Try sample to instantly load a small demo JSON object with a nested object, an array and a boolean so you can see Prettify, Minify and Tree mode working before pasting real data. Once you're done inspecting it, hit Clear next to the input panel to wipe the editor back to empty and start fresh with your own JSON.

usage

How JSON Prettify helps you get it done

Real problems it solves every day — for businesses, creators, and everyday tasks. Find the use case that fits you and start in seconds.

For Developers

API 响应调试

从开发者工具中粘贴压缩过的 API 响应,即可立即看到带缩进的结构。无需启动 JSON 查看器扩展,就能发现缺失字段、校验数据结构,并确认 null 与 undefined 的处理方式。

For Developers

配置文件清理

在解决合并冲突后,将杂乱的 package.json、tsconfig.json 或 .eslintrc.json 重新整理成易读的格式。一分钟内完成格式化、检查无误并提交一个干净的版本。

For Developers

数据库导出检查

在导入前检查从 MongoDB、DynamoDB 或 Firestore 导出的 JSON。验证其结构是否符合你的架构,确认没有记录出现意外的 null 冲突。

For Developers

Webhook 负载检查

捕获来自 Stripe、GitHub、Linear 或 Slack 的 webhook 载荷并美化输出,以理清其结构——这在构建集成或排查缺失的事件字段时必不可少。

For Developers

代码审查助手

将审查者提供的 JSON 示例以完整美化的形式粘贴到 PR 描述中,或在聊天空间有限时用「压缩」缩小体积。无论哪种方式,文件都有效且可安全复制粘贴。

Privacy & Security

生产环境密钥处理

由于一切都在您的浏览器中运行,您可以粘贴生产环境的机密数据来检查它们,无需任何网络往返——这正是 DevOps 团队所需、而云端 JSON 工具无法安全提供的工作流程。

For Developers

Explore Massive GraphQL & Nested API Responses

Switch to Tree mode to expand only the branches you care about in a huge nested payload, instead of scrolling a wall of prettified indentation to find one field.

Productivity

Prep Request Bodies for Postman & Insomnia

Paste a rough JSON body, prettify it to check the shape is right, then Minify before saving it into a Postman or Insomnia collection so it stores compactly.

Education

Teach JSON Structure to New Developers

Use Tree mode's collapsible nested view to walk bootcamp students or junior engineers through how objects and arrays nest, without them getting lost in raw indentation.

For Business

Tidy Log Exports Before Filing a Support Ticket

Paste a minified error log or JSON blob copied from your monitoring tool, prettify it into a readable format, and paste the clean version into a support ticket or Slack thread.

For Developers

Validate Config Files Before Committing

Paste a package.json, tsconfig.json or other JSON config file to catch a stray trailing comma, unmatched bracket or unquoted key via the native JSON.parse error message — before a malformed config breaks your build or CI pipeline.