JSON Formatter
Expand one-line JSON with indentation and fold blocks to follow the structure.
Paste JSON that arrives without line breaks, such as an API response, and the formatter indents it so it is readable. It parses with the browser's JSON.parse and writes the result back, so invalid syntax produces an error location instead of a formatted result. Pasted JSON never leaves the page.
Turning Sort Keys on and off
Paste the line below. Live is on, so the result appears immediately. Indentation starts as Tab and can be 2 or 4 spaces.
{"b":1,"a":[true,null],"C":"x","10":0,"2":0}
| Setting | Key order | Stats |
|---|---|---|
| Sort Keys off | 2, 10, b, a, C | 5 keys, 1 arrays |
| Sort Keys on | 2, 10, C, a, b | 5 keys, 1 arrays |
| Minify | One line, no spaces, no sorting | Result size 44 B |
Sorting follows character codes, so capital C comes before lowercase a. Number-like keys such as 2 and 10 go first in numeric order even with sorting off, because that is how JavaScript objects store keys. Array order is never changed. When comparing a dev and a production response, sort both and paste them into the diff checker, and only the lines with different values remain.
Finding the line and column of an error
For invalid JSON, the browser's English message is shown followed by a line and column the tool calculates. These are common Chrome messages.
| Input | Message begins | Cause |
|---|---|---|
{"a":1,} | Expected double-quoted property name | Trailing comma |
{'a':1} | Expected property name or '}' | Single quotes |
[1,2 | Expected ',' or ']' after array element | Missing bracket, common when a response is cut off |
| Two objects on separate lines | Unexpected non-whitespace character after JSON | JSON Lines; paste one line at a time |
{"a": 01} | Unexpected number | Leading zero |
Line and column refer to the input box. The position in the message counts from 0, so it is one less than the column. To check syntax only, there is the JSON validator.
Large inputs and big numbers
Above 500,000 bytes, folding is turned off and only the first 20,000 characters are displayed; Copy still copies the full result. An integer beyond 2 to the 53rd power, such as 9007199254740993, becomes 9007199254740992 the moment it is parsed, so send such values as strings. JSON stored inside a string ({"payload":"{\"id\":42}"}) is shown as a plain value. Changing the input or options redraws the result and unfolds your folded blocks, so press Collapse All again.
Standard JSON allows no comments, single quotes or trailing commas. Remove the comments from files like tsconfig.json before pasting.