How to use the JSON Formatter
- Paste your JSON into the Input box, drop in a file with Open file, or click Sample to try it.
- Choose Beautify (2 spaces, 4 spaces or tabs) or Minify. The output updates as you type.
- If the JSON is invalid, read the exact line and column of the problem and click Jump to error to select it.
- Switch the output to Tree to explore nested objects, and tick Sort keys for a stable, diff-friendly order.
- Copy the result or download it as a .json file.
What a JSON formatter does
JSON (JavaScript Object Notation, standardised as RFC 8259 and ECMA-404) is the default data format for web APIs, configuration files and logs. Machines are happy with it on a single line, but people are not: a 40 KB API response with no line breaks is unreadable. A formatter parses the text into a data structure and prints it again with consistent indentation, one key per line, so you can scan it, review it and spot mistakes.
This tool does three jobs at once. It validates the input against the JSON grammar, beautifies or minifies it, and gives you a tree view for exploring deep structures. Parsing happens in your browser with the built-in JSON.parse, so API keys, customer records or tokens inside your payload never leave your device.
Beautify vs minify
| Mode | Output | Use it for |
|---|---|---|
| Beautify (2 spaces) | Indented, one value per line | Reading, code review, committing config files |
| Beautify (4 spaces / tab) | Wider indentation | Matching a project style guide or editor setting |
| Minify | All insignificant whitespace removed | Sending over the network, embedding in env vars or HTML |
Whitespace between tokens has no meaning in JSON, so formatting never changes the data. The stats panel shows the exact effect: switch between modes and compare the input and output sizes. On deeply nested API responses, removing indentation commonly saves a quarter or more of the bytes before compression.
The most common JSON errors (and how to fix them)
JSON is stricter than JavaScript object literals. When validation fails, this tool reports the exact line and column and shows the offending line with a caret under the problem. These are the mistakes it catches most often:
- Trailing commas —
[1, 2, 3,]or{"a": 1,}are valid in JavaScript but not in JSON. Delete the last comma. - Single quotes — strings and property names must use double quotes:
{"name": "Ada"}, never{'name': 'Ada'}. - Unquoted keys —
{name: "Ada"}is a JavaScript literal, not JSON. - Comments —
//and/* */are not allowed. If your file has them, it is probably JSONC or JSON5 (used by some editors and tsconfig files). - Raw line breaks inside strings — a newline in a string must be written as
\n. - Special values —
undefined,NaN,Infinityand functions do not exist in JSON. Usenullor a string instead. - Leading zeros and hex —
007and0xFFare invalid numbers; write7and255.
Worked example
Suppose an API returns {"id":42,"tags":["a","b",],"ok":true}. The validator stops at line 1, column 26 with "Trailing comma before ]", because after the comma following "b" it expected another value but found a closing bracket. Remove that comma and the formatter prints:
{
"id": 42,
"tags": [
"a",
"b"
],
"ok": true
}
The stats panel then reports 3 keys, a maximum depth of 2 (the object and the array inside it) and the output size compared with the input.
Sorting keys for clean diffs
JSON objects are unordered by specification, but serializers usually keep insertion order, so two equivalent documents can look very different in a diff. Ticking Sort keys A–Z sorts every object recursively (arrays keep their order, because array order is meaningful). Format both files this way and paste them into the diff checker to see only the real changes.
Large numbers lose precision
JavaScript stores every number as a 64-bit float, so integers above 253 − 1 (9,007,199,254,740,991) are rounded when parsed. Database IDs such as Twitter/X snowflakes or 64-bit counters are the usual victims. This tool warns you when an integer in your input is too large to survive a round trip; the safest fix is to send such IDs as strings.
Tips
- Need a spreadsheet instead? Convert an array of objects with the JSON to CSV converter.
- Decoding a token? The payload of a JWT is Base64URL-encoded JSON — paste the middle part of the token into the Base64 decoder to read it.
- JSON embedded in a query string must be percent-encoded first; the URL encoder handles that.
Frequently asked questions
Is it safe to paste sensitive JSON here?
Why does my JSON say "Unexpected token"?
Does formatting change my data?
Can I format JSON with comments (JSONC) or JSON5?
How large a file can I format?
What is the difference between JSON and a JavaScript object?
Last reviewed November 2026. Results are estimates for information only — see our disclaimer.