JSON Formatter
Paste JSON, pick an indent width, and get readable output. If the syntax is broken, you get the line and column instead of a vague failure.
How to use the JSON Formatter
- Paste or type your JSON into the input box. Nothing is uploaded — parsing happens in your browser.
- Choose an indent width of 2 spaces, 4 spaces or a tab, and optionally sort object keys alphabetically.
- Press Format JSON (or Ctrl + Enter), then copy or download the result.
What JSON formatting actually does
Formatting doesn't change your data — it changes the whitespace around it. A parser reads {"a":1} and {
"a": 1
} identically. What changes is how easily a human can follow the nesting.
This tool runs JSON.parse on your input and then re-serialises it with JSON.stringify. That round trip is why formatting doubles as validation: if the parse fails, the input was never valid JSON to begin with. It also means key order is preserved exactly as written, unless you switch on alphabetical sorting.
One side effect worth knowing: the round trip normalises values. 1.50 comes back as 1.5, 1e3 becomes 1000, and duplicate keys collapse to the last one that appeared. That is standard JSON behaviour, not a bug in the formatter.
Errors this tool catches, and what they mean
| Message | Usual cause |
|---|---|
Unexpected token } | A trailing comma after the last item. JSON forbids them; JavaScript allows them. |
Unexpected token ' | Single quotes. JSON strings must use double quotes. |
Unexpected token o | Usually a bare word like ok, or a Python-style None/True instead of null/true. |
| Unexpected end of input | A brace or bracket was never closed. |
| Unexpected non-whitespace character after JSON | Two JSON documents pasted back to back, or a stray character at the end. |
The error line and column point at where the parser gave up, which is often one or two lines after the real mistake. If line 12 looks fine, check the end of line 11.
Comments, trailing commas and JSON5
Strict JSON has no comments. // and /* */ will both fail here, which is correct behaviour — a config file that accepts them is using JSON5, JSONC or YAML, not JSON. If you are editing a tsconfig.json or a VS Code settings file, strip the comments before formatting, or expect this tool to reject it.
Frequently asked questions
Is my JSON sent to a server?
No. The parsing and formatting run in your browser using the built-in JSON engine. Nothing is transmitted, logged or stored, which makes this safe for API responses containing tokens or customer data.
Why did my large numbers change?
JavaScript numbers lose precision above 2⁵³ − 1. An ID like 9007199254740993 may come back as 9007199254740992. If you work with large integers, store them as strings in JSON.
What is the difference between formatting and validating?
They are the same parse step with different output. Formatting shows you the beautified document; validating just reports pass or fail. If formatting succeeds, your JSON is valid.
Can it handle a very large file?
Files up to a few megabytes are fine on a modern machine. Beyond roughly 10 MB the browser has to hold the raw text, the parsed object and the output string in memory at once, so expect it to slow down.
Does sorting keys change my data?
It changes the order keys appear in the file. JSON objects are formally unordered, so most parsers do not care — but if something downstream depends on key order, leave sorting off.
Related tools
Check whether JSON is valid and see exactly where it breaks.
Strip whitespace from JSON and see how many bytes you saved.
Encode text or files to Base64, with URL-safe output available.
Percent-encode text for URLs, query strings and form data.
Re-indent JavaScript so nesting and blocks are readable.