How to use the JSON Formatter & Validator
- Paste JSON into the input box, or load the sample to see how it works.
- Press Format to indent it with 2 or 4 spaces, or Minify to remove all whitespace.
- If the JSON is invalid, read the error message, which describes what the parser found and where.
- Switch to the tree view to collapse and expand nested objects and arrays, then copy or download the result.
How it works
The input is parsed with the browser's built-in JSON.parse, which follows the JSON standard (RFC 8259). If parsing succeeds, the data is printed back with JSON.stringify using your chosen indentation; minifying prints it with no whitespace at all.
Valid input is parsed and re-printed as JSON. Object key order and duplicate keys may change, and numbers outside JavaScript precision can lose digits. Keep large integer identifiers as strings when exact digits matter.
Input: {"a":1,"b":[true,null]}
Format: {
"a": 1,
"b": [ true, null ]
}Worked example: finding a syntax error in an API response
A common mistake is a trailing comma, as in {"id": 1, "tags": ["a", "b",]}. JSON does not allow a comma before a closing bracket, so the formatter reports a syntax error instead of producing output.
Removing the comma after "b" fixes it. Other frequent errors are single quotes instead of double quotes, unquoted keys, and comments, none of which are valid JSON.
| Not valid JSON | Valid JSON |
|---|---|
| {'name': 'Ana'} | {"name": "Ana"} |
| {name: "Ana"} | {"name": "Ana"} |
| [1, 2, 3,] | [1, 2, 3] |
| {"n": 01} | {"n": 1} |
Limitations
- Very large files (tens of megabytes) can make the page slow, because the whole document is held in memory and rendered.
- Numbers larger than about 9 quadrillion (2^53) lose precision in JavaScript, so very large integer IDs can change when reformatted. Keep such IDs as strings.
- JSON5, JSON with comments, and other extended formats are not accepted, because they are not standard JSON.
Frequently asked questions
Is my JSON sent to a server?
No. It is parsed and formatted in your browser, so API responses, tokens, and configuration files stay on your device.
Why does my JSON with comments fail?
Standard JSON does not allow comments. Remove them, or keep the file in a format that supports them, such as JSON5 or YAML.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation for reading. Minifying removes all unnecessary whitespace to make the data as small as possible for sending over a network.
Does formatting change my data?
It parses and re-serializes JSON rather than editing whitespace alone. Duplicate object keys collapse to the last value, object key order and number representation can change, and numbers outside JavaScript precision can lose digits. Keep the original when exact source text matters, and use strings for large integer identifiers.