JSON formatter & validator
Format JSON with the indent you want, minify it back down, sort its keys, and get the line and column of a syntax error rather than a message about position 4,812.
Your JSON
Your JSON stays in this tab. The work is done by JavaScript in your browser. None of it is uploaded, logged or saved, and the tool keeps working with the network off.
How to print it
Formatted
Formatted JSON appears here as you type.
Where it runs
In your browser, using the same JSON.parse your own code uses. Nothing is uploaded and nothing is stored: load the page, disconnect the network, and it still works. That matters for this tool more than most, because the JSON a developer needs to read is usually a real response from a real system, and quite often has somebody’s data in it.
Using the browser’s own parser is a deliberate choice rather than a shortcut. A hand-written parser would be a second opinion about what counts as valid JSON, and the opinion that matters is the one held by the runtime your code will use.
The four things that are not JSON
Almost every “but it looks fine” turns out to be one of these. All four are perfectly good JavaScript, which is exactly why they catch people out.
- Trailing commas.
{"a": 1,}and[1, 2, ]are both rejected. - Single quotes. JSON strings and keys use double quotes, always.
- Unquoted keys.
{a: 1}is an object literal, not JSON. - Comments. There is no comment syntax in JSON at all.
Two things JSON quietly changes
Duplicate keys collapse. {"a":1,"a":2} is valid, and every parser keeps the last one. The formatted output has a single key and the first value is simply gone. The tool does not do this to you. Your code does the same thing, but it is worth seeing before you assume the output matches the input.
Large numbers lose precision. JSON has no integer type, so numbers become double-precision floats holding about fifteen significant digits. An ID of 12345678901234567890 comes back as 12345678901234567000. Anything above 9,007,199,254,740,991 has to be quoted as a string in the JSON itself to survive; no formatter can recover one that was not.
Sorting keys, and when to
Key order carries no meaning in JSON, so sorting changes nothing about what a document says. What it changes is comparability: two config files written by different people, or two API responses from different versions, become byte-identical if their contents match, and a diff shows only real differences instead of reshuffling.
Array order is never touched, because there it is the data. An array is a sequence and reordering it would be changing the document rather than tidying it.
Questions
Is my JSON sent anywhere?
Why does it say my JSON is invalid when it looks fine?
Why does the error sometimes not give a line number?
What happened to my duplicate keys?
Why did my long ID number change?
What does sorting the keys do?
What is the difference between minified and formatted JSON?
Can it handle a large file?
More tools
Base64 encoder / decoder
Both directions, both alphabets, Unicode included
URL encoder / decoder
Percent-encoding, with the component and whole-URL rules apart
Robots.txt tester
See which rule a crawler actually applies