跳到正文

STEMSTUDIO

Format JSON and find what is broken

Data · formatted on this device

Format JSON and find what is broken

Pretty-print, minify or sort JSON. If it is broken, see exactly which line and why.

  • Free, no account
  • Nothing is sent

Help

The position and reason above are worked out by this page. This is the browser’s own wording, kept for reference. These come from a text search, so one of them may simply be sitting inside a string value.

Processing, communication and stored data

粘贴 JSON 即可美化、压缩或按键排序。解析失败时,会给出行和列,引用出错的那一行并在下面用 ^ 标出位置,还会用简单的话说明尾逗号、注释等 JSON 悄悄禁止的东西。

支持格式

JSON

常见问题

我粘贴的 JSON 会被上传吗?

不会。解析、格式化和校验都在页面中进行,粘贴的内容从不发送到服务器。关闭标签页就消失。

能处理多大的输入?

没有硬性上限——取决于你的设备。几 MB 很轻松。大约超过 200KB 时实时格式化会关闭,出现一个“格式化”按钮,因为每次按键都重新解析几 MB 会让打字本身卡顿。

能帮我修复坏掉的 JSON 吗?

不能。删掉尾逗号是安全的,但把单引号换成双引号可能会弄坏字符串里的撇号。所以不会自动改写,而是显示位置和原因。

行号是浏览器给的吗?

不是——交给浏览器,正是大多数格式化工具无法显示行号的原因。输入稍长时,Chrome 返回的是片段而不是位置,Safari 则从不包含位置。所以这个页面自己分析语法,找到文档最先出错的地方,再从那里数出行和列。说明(“这个逗号后面什么都没有”)也来自同一次分析;浏览器自己的提示保留在下面供参考。格式化仍由浏览器的标准解析器完成,所以输出和其他地方读取 JSON 的方式一致。

按键排序有什么用?

让对比稳定。内容相同但键的顺序不同的两个文件,比较时会产生干扰;先把两者都排序,就只剩真正的差异。顺序按 Unicode 码元排列,在任何机器上都一样。

Ratings from users

Ratings appear once there are 10.

Report a problem or suggest something

The tool name, this page’s path and your browser type are sent with it. Files are never sent. For a reply, use the email on the Contact page.