How the JSON formatter works
The tool runs JSON.parse() on your text. If it parses, the object is re-serialised with JSON.stringify(value, null, 2), which indents every nesting level by two spaces. That means {"a":1,"b":[2,3]} becomes a block where "a": 1 and "b": [2, 3] are on separate lines. Key order is preserved exactly as written; only whitespace changes.
Groups often move straight on to the URL encoder afterwards.
How to use it
Paste your JSON into the box and read the result below. A green-style badge shows the line and character count when the document is valid. If it is not, you get the exact parser message, such as an unexpected token and its position, which usually points straight at a trailing comma or an unquoted key. Everything runs locally in your browser, so nothing is uploaded. Need to move data in and out of transport encodings? Try the Base64 encoder.
The Base64 decoder is the obvious companion when this one is not quite the right shape.
Common JSON mistakes
Most invalid JSON comes from a handful of habits carried over from JavaScript:
| Mistake | Fix |
|---|---|
| Trailing comma | Remove the comma before } or ] |
| Single quotes | JSON strings require double quotes |
| Unquoted keys | Wrap every key in double quotes |
| Comments | JSON has no comment syntax |
| NaN or undefined | Use null or a real number |
To escape a JSON snippet for display in a web page, use the HTML encoder.
If the parser points at a position near the end of a long document, the real error is usually earlier: an unclosed brace or bracket only becomes invalid when the file runs out.
Frequently asked questions
- Does this formatter send my JSON anywhere?
- No. Parsing and formatting happen entirely in your browser with JavaScript, so the data never leaves your device.
- What indentation does it use?
- Two spaces per nesting level, the most common convention for configuration files and API payloads.
- Can it validate JSON as well as format it?
- Yes. If the text cannot be parsed, the tool shows the exact error message from the JSON parser instead of formatted output.
- Will it reorder my keys?
- No. Keys keep the order they appear in your source text; only whitespace and line breaks change.
- Can it handle very large JSON files?
- It can, but a browser tab will slow down once a document reaches several megabytes, because the whole string is parsed and re-serialised in memory. For files that big, use a streaming parser or a command-line tool such as jq instead.