JSON Formatter

Paste minified or messy JSON and get readable, indented output with instant validation.

json-formatter
Result
—
In summary: Paste {"a":1,"b":[2,3]} and this formatter returns it indented with 2 spaces, so "a": 1 and "b": [2, 3] each sit on their own line. If the text is not valid JSON, the tool shows the parser error message instead of output, which makes it a quick syntax check as well as a beautifier.

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:

MistakeFix
Trailing commaRemove the comma before } or ]
Single quotesJSON strings require double quotes
Unquoted keysWrap every key in double quotes
CommentsJSON has no comment syntax
NaN or undefinedUse 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.
How this tool works

The formula behind this tool is written out in full in the sections above, so you can check the maths yourself. Every calculator on Calculorium is verified against worked examples with automated tests before it is published, and pages are reviewed as formulas or standards change. Nothing you type is sent anywhere — the calculation runs entirely in your browser. Read how we build and check these tools.

Last updated: October 2, 2026 · Calculations run in your browser. Estimates for information only.