JSON Formatter
Beautify JSON with 2-space indentation, right in your browser.
What is JSON Formatter
JSON formatting adds line breaks and indentation to minified JSON, making it readable. Useful for inspecting config files and API responses.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
Parsing first, printing second
The input is passed through JSON.parse and re-serialised with two-space indentation. Because it is a real parse rather than a text reformatter, anything JSON does not allow is rejected with a position — trailing commas, comments, single-quoted strings, unquoted keys, and NaN all fail here even though JavaScript source accepts them.
The error message names a character offset, which is the practical way to find the problem: count to that offset in the original string. Most failures are a trailing comma before a closing brace, or a smart quote introduced by a word processor when the payload was copied out of a document.
What the round trip silently changes
Comments are gone, because JSON has no comments — if the source used JSONC or JSON5, they are not recoverable from the output. Duplicate keys collapse to the last occurrence. Key order is preserved for string keys, but integer-like keys are reordered first, since JavaScript objects treat them as array indices.
Numbers are the dangerous part. Anything beyond 2^53 loses precision: 12345678901234567890 comes back as 12345678901234567000. Snowflake IDs, Twitter/X IDs, database bigints and Ethereum wei values are all in that range, and the corruption is silent. If the payload carries large integers, treat them as strings at the source rather than reformatting them here.
Formatting is not validation
A document that parses is syntactically valid JSON, not correct data. Duplicate keys, wrong types, missing required fields and a number where a string was expected all pass. If you need schema checking, that is a separate step with a JSON Schema validator.
The practical limit is size: parsing builds the entire object in memory, so a multi-megabyte document is fine and a hundred-megabyte one will freeze the tab. For files that large, use a streaming formatter rather than a browser page.
How to use it
- 1.Paste your JSON
- 2.Click Format
- 3.Copy the result
How JSON Formatter works under the hood
Formatters parse your input into a structure, then serialise it back with consistent indentation. That is why a formatter can also reveal a syntax error: if it cannot parse, it cannot print.
- 1
Parse into a tree
JSON goes through JSON.parse; YAML, XML, CSS and SQL use their own parsers. The parse either succeeds with a structure or fails at a line and column.
- 2
Serialise with a fixed style
Indentation width, key order and quoting are applied deterministically, so formatting the same input twice gives identical bytes.
- 3
Show the error position
When parsing fails, the message includes the position so the fix is obvious instead of guessed.
Processing pipeline
Formatting is not validation
A formatter proves the document is syntactically parseable. It does not prove it is valid against a schema, and it does not check business rules. JSON with a duplicated key parses fine and silently keeps the last value.
What gets normalised
Comments are preserved in CSS and SQL but not in JSON, which has no comment syntax. YAML anchors may be expanded, and quote style may change. Keep the original when exact byte layout matters, such as signed payloads.
Verify it yourself
Formatting is deterministic and local — run it twice and compare.
- 1.Open DevTools on this page and switch to the Network tab
- 2.Keep the filter on Fetch/XHR and run the tool
- 3.Confirm no request carries your file — you should see only page assets and fonts
Frequently asked questions
What is JSON formatting?
It adds line breaks and indentation to make JSON readable.
What about invalid JSON?
A syntax error message is shown if the JSON is malformed.
Is data uploaded?
No, everything runs in your browser.
What this kind of conversion cannot keep
Formatters parse the input into a tree and print it back with consistent indentation. If the input is invalid, you get the parser's error position instead of a silently mangled file — malformed JSON stays malformed rather than being «repaired» into something that is no longer yours.
More in Format
On this page
- What is JSON Formatter
- What this tool actually does with your file
- How it actually behaves
- How to use it
- How it works inside
- Frequently asked questions
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →