JSON 是什么
JSON(JavaScript Object Notation)是目前使用最广泛的轻量级数据交换格式。接口返回、配置文件、日志导出,几乎处处都是它。可一旦数据多了、嵌套深了,肉眼几乎没法看:缩进混乱、字符挤成一团,复制到别处还经常报错。
这个工具能做什么
打开 JSON 格式化工具,把代码贴进输入框,工具会同时做三件事:
- 美化(Prettify):自动缩进对齐,并给键值对上色,层级一目了然。
- 压缩(Minify):去掉所有空白,把 JSON 压成一行,适合塞进缓存、数据库或请求参数。
- 校验(Validate):语法出错时实时标出在第几行、第几列、具体是什么问题,不用再自己对逗号和括号。
常见踩坑
- 尾逗号:最后一个字段后面不能有逗号,很多手写 JSON 都栽在这里。
- 键必须加双引号:单引号或裸键都是非法写法。
- 中文不用转义:JSON 原生支持 Unicode,中文可以直接写,美化后不会乱码。
什么时候压缩,什么时候美化
调试接口时用美化看结构;写入缓存、数据库或缩短 URL 时用压缩减小体积。两者在工具里一键切换,校验结果始终实时显示。
所有处理都在你的浏览器本地完成,数据不会上传到任何服务器。
What is JSON?
JSON (JavaScript Object Notation) is the most widely used lightweight data format — API responses, config files, and log exports all speak it. The trouble starts when you need to read it: deeply nested data with inconsistent indentation and crammed characters is nearly impossible to scan by eye.
What this tool does
Open the JSON formatter, paste your text, and the tool does three things at once:
- Prettify — auto-indents and colors keys and values so the hierarchy is instantly readable.
- Minify — strips all whitespace and collapses the JSON to one line, ideal for caches, databases, or request payloads.
- Validate — flags syntax errors in place, pointing at the exact line and column instead of guessing where the comma belongs.
Common pitfalls
- Trailing commas — the last field must not end with a comma; most hand-written JSON fails here first.
- Keys must be double-quoted — single quotes or bare keys are invalid.
- Unicode is native — Chinese characters can be written directly; formatting will never garble them.
Prettify vs. minify
Use prettify while debugging to see structure; use minify when writing to storage, caches, or shrinking URLs. One click switches between them, and validation is always live.
Everything runs locally in your browser — nothing is ever uploaded.