Format messy JSON with consistent indentation, minify it back to one line, and get exact error positions when something is broken — "line 3, column 14" instead of a vague parse failure.
Formatting and validation both go through the browser's own JSON.parse, so what this page accepts is exactly what your code will accept — there is no second implementation here to disagree with the standard. What the page adds is the position: the engine reports a byte offset, and that is converted into the line and column you can actually go and look at.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing, formatting and error detection all run locally in your browser — safe for private data.
Why does my JSON fail on trailing commas?
The JSON standard does not allow a comma before } or ] — that is a JavaScript-only convenience.
What indent does the formatter use?
Two spaces, the most common convention for config files and API responses.
中文说明
把杂乱的 JSON 排版成统一缩进、或压缩成一行,并在格式有错时给出精确位置——"第 3 行第 14 列",而不是含糊的解析失败。
格式化与校验都走浏览器自带的 JSON.parse,所以本页接受什么、你的代码就接受什么——这里没有第二套实现去和标准打架。本页加的是「位置」:引擎报的是字节偏移量,这里把它换算成能直接去看的行号与列号。
常见问题
我的 JSON 会上传到服务器吗?
不会。解析、格式化和错误检测全部在浏览器本地运行,敏感数据也安全。
为什么尾逗号会报错?
JSON 标准不允许 } 或 ] 前出现逗号——那是 JavaScript 的特有语法。
格式化用几个空格缩进?
两个空格,这是配置文件和 API 响应最常见的约定。