Also available in: Español · Português · Français · العربية
JSON Formatter and Validator
Paste JSON, get it formatted, validated and explained, using a parser built from scratch so your numbers stay exactly as you typed them.
What is a JSON formatter?
A JSON formatter takes JSON text and rewrites it with consistent indentation, line breaks and spacing so a human can actually read it. A JSON validator is the other half of the same job: it checks that the text is syntactically correct JSON before anything tries to use it, and tells you exactly where it is not. Most tools bundle both, because the moment you are staring at a wall of minified API response or a hand-edited config file, you need both questions answered at once — is this valid, and can you make it readable.
This one does both entirely in your browser. Paste in JSON and it reformats as you type, checks it against the spec, and reports what it finds, right down to the character that broke it. What sets it apart is underneath: instead of leaning on the JavaScript engine's built-in JSON.parse, it runs its own parser, written specifically for this page. That single decision is why the number handling and the error messages below work the way they do.
How to use it
- Paste your JSON. Drop it into the text box, or click Load an example if you just want to see the tool work. It validates and reformats as you type, with no button to press first.
- Pick a format. Choose an indent from the pills: 2 spaces, 4 spaces, Tab, or Minify. Turn on Sort keys alphabetically if you want a deterministic key order, which is useful for diffs; it is off by default because reordering a document is a change you should ask for.
- Read the result. Check the status line, then copy the formatted output with the Copy button. If the document is invalid, the tool names the mistake, gives the line and column, and shows the source line with a caret under the exact spot — plus warnings for duplicate keys or numbers a double cannot hold, and a stats line covering keys, depth, values and size.
Why this tool has its own JSON parser
Almost every online JSON formatter runs your text through JSON.parse and JSON.stringify. That is fine for structure, but it is destructive for numbers: JavaScript converts every number to a double, and a double holds at most 17 significant digits. Paste {"id": 12345678901234567890} into a JSON.parse-based formatter and it comes back as {"id":12345678901234567000} — the last three digits are simply gone. Paste {"price": 0.1000000000000000055511151231257827} and it comes back as {"price":0.1}. Neither formatter told you anything changed.
This tool's parser keeps each number as the original text and re-emits it digit for digit, so formatting never alters a value. It also does the thing a silent round trip cannot: it names every number that a double cannot hold exactly, because the moment that value hits JSON.parse anywhere downstream — including whatever app you paste this output into — it will change. Preserving the digits here does not make them safe everywhere else, and the warning panel says so rather than letting you assume the problem is solved.
The same silent loss shows up with keys. {"id": 1, "name": "a", "id": 2} is valid JSON, but JSON.parse quietly keeps only the last occurrence, so you get {"id":2,"name":"a"} with the first value gone and no indication it ever existed. This tool reports every repeat with its line number and keeps both entries in the formatted output. That output is still JSON, though, so if you paste it into something that itself calls JSON.parse, that consumer will make the same choice and drop the earlier value again — the warning travels with this page, not with the text.
Error messages that name the mistake
Credit where it is due: modern Chrome and Node have got better at this. For {"a": 1,} the built-in parser now reports Expected double-quoted property name in JSON at position 8 (line 1 column 9), which is a real position you can jump to. That is a meaningful improvement over what these engines used to give you.
Two gaps remain. First, the position is not always there: {"a": True} produces only Unexpected token 'T', "{"a": True}" is not valid JSON, with no line or column at all. Second, even when a position shows up, it describes what the parser expected next, not what you actually typed. This tool instead names the mistake itself, recognising 18 distinct error kinds — a trailing comma, single quotes instead of double, an unquoted key, Python's True, False or None pasted into JSON, a comment, a leading zero, a literal newline inside a string — each reported with a line, a column and the source line. For a trailing comma it points at the comma itself rather than the closing brace where a generic parser happened to notice: on a sample four-line document, that is line 3, column 12, the comma exactly. Strict JSON is the only thing it accepts, so comments and trailing commas are reported as errors rather than quietly tolerated; if you actually want JSON5 or JSONC this is the wrong tool, though it will still tell you precisely which line to change.
None of that is worth much if the parser disagrees with the platform about what is valid, so it was checked against one: 20,000 generated documents, 13,323 of them deliberately corrupted by randomly inserting, deleting or replacing a character. This parser agreed with JSON.parse on validity in every single case — zero disagreements — and every document both accepted reformatted to something that parses back to an identical value. Formatting is idempotent, so formatting twice changes nothing, and empty objects and arrays stay compact as {} and [] instead of being spread across three lines. The one trade-off of a hand-written parser running on the page itself: it works on the main thread, so a file of several megabytes will make the tab pause while it grinds through.
Why is it free?
Because it runs entirely in your browser, there is no server processing your document and no reason to charge for it. There is no account to create, no watermark on the output, and no paid tier hiding a feature you actually need. That also settles the question you should be asking of any online formatter: config files and API responses are exactly the things people paste in without thinking, and this one has nowhere to send them.