全球免费使用

JSON 格式化与校验

在本地校验、美化或压缩 JSON。无效数据绝不会发送到服务器。

你的数据只保留在此标签页中。我们不会收到你的文件、粘贴的文本或计算数值。

输入

提示:按 Ctrl + Enter 运行

你的结果

结果将显示在这里。

下方的详细帮助目前仅提供英文版。

关于此工具

API responses, configuration files and log entries often arrive as one long line of JSON. This tool checks that the text is valid JSON and then either indents it for reading (pretty) or removes all unnecessary whitespace (minify) for sending or storing. Because it runs in your browser, you can safely format responses that contain customer data or access tokens.

If the input is not valid JSON, it tells you so rather than guessing. JSON is strict: keys and strings need double quotes, and trailing commas are not allowed.

使用方法

  1. Paste the JSON text.
  2. Choose pretty to indent it with two spaces, or minify to put it on one line.
  3. Run the tool.
  4. Copy or download the result; if you get an error, fix the reported problem and run it again.

计算原理

The text is parsed with the browser’s standard JSON parser and written back with JSON.stringify, either with two-space indentation or none. Key order and values are preserved; numbers keep their JavaScript double-precision value.

JSON.parse → JSON.stringify

计算示例

An order API returns {"order":1042,"items":[{"sku":"A-1","qty":2}],"paid":true}. Pretty mode lays it out over ten lines with nested indentation, making it obvious that "items" is an array containing one object with "sku" and "qty". Pasting {'a':1} with single quotes instead gives an invalid JSON error.

示例输入和结果

{"a":1}

局限性

  • Strict JSON only (no JSON5 comments or trailing commas).
  • Integers above 2^53 lose precision.
  • Up to 100,000 characters.

最后更新:

常见问题

Why is my JSON rejected?

Common causes are single quotes, trailing commas, comments, unquoted keys and special values like NaN. These are allowed in JavaScript but not in JSON.

Does it change my data?

No, except that very large or very precise numbers are limited to JavaScript’s number precision (about 15–17 significant digits).

Can it sort keys?

No. Keys stay in their original order.

故障排除

Large IDs changed their last digits.

Numbers above 9,007,199,254,740,991 cannot be stored exactly. Ask the API to send IDs as strings.

It fails on a file copied from a log.

Logs often contain several JSON objects, one per line. Format one object at a time.

I need YAML.

Use the JSON ↔ YAML converter.

隐私 & 免费使用

我的输入会被保存吗?

你的数据只保留在此标签页中。我们不会收到你的文件、粘贴的文本或计算数值。

这个工具免费吗?

是的。无需注册或付费。

在浏览器中处理

推荐下一步