How to use the JSON formatter
- Paste your JSON into the box. Up to 1,000,000 characters are accepted.
- Pick an indentation: 2 spaces, 4 spaces or a tab.
- Press Format to pretty-print it, Minify to remove all optional whitespace, or Validate to check it without producing output.
- Use Copy result to put the output on your clipboard.
If the JSON is invalid, the result card shows the line and column of the first problem, a short reason and the offending line with a caret under the exact spot. The position is also selected in the input box so you can fix it straight away.
Your data stays on your device
Everything happens in your browser. The JSON you paste is never sent to our server, so it is safe to use with configuration files, API responses and other private data.
How it works
The tool reads the text once from start to finish and checks it against the JSON grammar (RFC 8259): objects, arrays, double-quoted strings, numbers, true, false and null. While reading, it writes each piece back out with the whitespace you chose.
Because strings and numbers are copied exactly as written, nothing is changed by accident. Large numbers such as 12345678901234567890 keep every digit, escape sequences like \u00e9 stay as they are, and repeated keys are kept in their original order.
Worked example
Formatting {"name":"Ada","tags":["math","code"],"active":true} with 2 spaces gives 8 lines: the opening brace, one line for each property, the two array items indented by 4 spaces, the closing bracket of the array and the closing brace. The nesting depth is 2.
Now take this input, which has a comma after the last property:
- line 1:
{ - line 2:
"name": "Ada", - line 3:
"age": 36, - line 4:
}
With two spaces of indentation on lines 2 and 3, the tool reports line 3, column 12 and the message "Trailing comma: remove the comma before the closing brace".
Good to know
- JSON does not allow comments, trailing commas, single quotes or unquoted words such as undefined and NaN. These are the most common errors and each gets its own message.
- Only one top-level value is allowed. To keep several records together, put them in an array.
- An invisible byte order mark at the very start of a file is ignored.
- Column numbers count characters, so an emoji counts as one column.