贴进去,格式化或压缩;有错就指出第几行第几列。 Paste it, pretty-print or minify. If it's broken, you get the line and column.
接口返回的 JSON 往往被压成一行,几千个字符挤在一起,层级关系完全看不出来。格式化就是按缩进把嵌套展开:对象换行、数组逐项、键值对齐,一层一层往右退。改配置、比对两份返回、在嵌套五层的结构里找那个写错的字段,都靠这个。缩进宽度选 2 还是 4 纯看习惯,压缩则相反——去掉所有可省略的空白,把结果缩到最小,通常只有格式化后的六成体积。 API responses often come back as one long line where thousands of characters sit shoulder to shoulder and the nesting is invisible. Pretty-printing expands it by indentation: each object breaks across lines, arrays list one item per line, and every level steps in. It's how you edit a config, diff two responses, or find the one wrong key five levels down. Whether you indent by 2 or 4 is taste; minifying does the opposite — dropping every optional whitespace character, usually to about sixty percent of the pretty-printed size.
JSON 规范里对象是无序的,但文本比对是有序的。同一份数据,如果两个系统生成的键顺序不同,直接 diff 会满屏标红,实际内容却一模一样。按键名递归排序(所有层级都排,不只是最外层)之后,两份结构相同的 JSON 逐行对齐,真正的差异才会显出来。这也是提交配置文件前的一个好习惯:排序过的文件,改动只出现在真正改了的地方,而不是因为键换了位置就整段变色。 The JSON spec treats objects as unordered, but text diffs are ordered. If two systems emit the same data with different key order, a naive diff lights up every line while nothing actually changed. Sorting keys recursively — every level, not just the top — aligns two structurally identical documents so only real differences show. It's also a good habit before committing a config file: a sorted file changes only where you actually changed something, instead of recolouring whole blocks because a key moved.
浏览器的 JSON 解析器会给出一个字符偏移量(position),但不会直接说「第几行」。本工具把偏移换算成行列:从开头数到那个字符,遇到换行就加一行、列数归零。绝大多数错误是这三类——多余的尾逗号({"a":1,})、用了单引号(JSON 只认双引号)、注释(JSON 不支持注释)。还有一类特别隐蔽:从聊天软件复制时混进了全角引号或不可见字符,肉眼看没问题,解析器一读就炸。遇到「明明看着对却报错」,先把内容重新敲一遍,多半就好了。
Browser JSON parsers report a character offset (position), not a line number. This tool converts the offset into a line and column by counting from the start and resetting the column at each newline. Nearly all errors fall into three groups: trailing commas ({"a":1,}), single quotes (JSON only accepts double), and comments (JSON has none). One nastier case: copying from a chat app can smuggle in full-width quotes or invisible characters — visually identical, instantly fatal to the parser. When something “looks right” and still fails, retype it before debugging anything else.
解析在浏览器里完成,几 MB 的 JSON 也能处理,但超过约 10 MB 时页面会明显卡顿——那是主线程被JSON.parse占满了,不是出错。这类文件建议用命令行 jq。至于内容本身:请求里可能带 token、手机号、内部地址,所以本工具一个字也不上传,断网也能用。你可以关掉网络再打开这一页验证。
Parsing happens in the browser, so multi-megabyte documents work, though past roughly 10 MB the page visibly stalls — that's JSON.parse occupying the main thread, not a failure. For files that large, use jq on the command line. As for content: requests often carry tokens, phone numbers and internal hostnames, so nothing here is uploaded and the page works offline. Turn off your network and reload it to confirm.
不支持,严格按 JSON 规范解析,注释和尾逗号都会报错。如果你在整理 tsconfig、devcontainer 这类带注释的文件,先把注释删掉;这类文件本来就该用支持注释的编辑器处理。 No — it parses strict JSON, so comments and trailing commas are errors. If you're tidying a file like tsconfig or devcontainer that legitimately carries comments, strip them first; those formats belong in an editor that understands them.
不能一次处理,因为整体不是合法 JSON。要么把整个文件包成数组(首尾加 [ ]、行间加逗号),要么用 jq -s 这类工具转换。日志和数据集常见这种格式。
Not as a whole, since the file isn't valid JSON. Either wrap it in an array (add [ ] and commas between lines) or convert with something like jq -s. Logs and datasets use this shape often.
排序按字符串比较,所以 "10" 会排在 "2" 前面。这是有意的:JSON 对象键本来就是字符串,按字符串排才能保证结果稳定。如果数字键有业务含义的顺序,请改用数组。
Sorting is lexicographic, so "10" lands before "2". That's deliberate: JSON object keys are strings, and string order is the only stable choice. If numeric-keyed order carries meaning, use an array instead.