How to Format and Validate JSON Online for Free
JSON arrives from an API as one unbroken line, and somewhere in those four thousand characters is the field you need or the bracket you forgot. The JSON Formatter indents it so the structure is visible and tells you where it is invalid.
What formatting actually does
Formatting changes nothing about the data. It adds the line breaks and indentation a machine does not need and a person cannot read without. An object becomes a block, its keys line up underneath each other, and nesting becomes visible as depth on the page rather than as a count of brackets.
That matters most when something is wrong. A missing comma in one line of minified JSON is invisible. The same file indented shows you the line, and the indentation itself often reveals the problem - a block that does not close where you expected is a block whose brackets are unbalanced.
The four mistakes behind nearly every error
A trailing comma. JavaScript allows a comma after the last item in an object or array. JSON does not, and this is far and away the commonest failure, usually caused by deleting the last entry and leaving its comma behind.
Single quotes. JSON requires double quotes on both keys and string values. Code pasted from a JavaScript file or a Python dictionary frequently brings single quotes with it.
Unquoted keys. A key must be a quoted string. Again, valid JavaScript, invalid JSON.
A stray value. Comments are not part of JSON at all, and neither are undefined, NaN or Infinity. Any of them makes the whole document invalid.
Reading the error message
A validator reports a position, not an intention, so it tells you where parsing became impossible rather than where you made the mistake. A missing comma on line 12 is often reported at line 13, because line 12 was still legal until the next thing arrived. Look at the line before the one named and the cause is usually there.
Common questions
Is my data uploaded anywhere?
No. The formatting and validation run in your browser, which matters when the JSON contains customer records or API keys.
Can I make JSON smaller again?
Minifying removes the whitespace a formatter adds. It is worth doing for data you are transmitting and pointless for a file you are reading.
How do I see what changed between two versions?
Formatting both and comparing by eye works for small files and not for large ones. The JSON Diff Checker reports the actual differences instead.
Does a valid JSON file mean my data is correct?
No. Validation checks the syntax, not the meaning. A perfectly valid document can have the wrong field names, missing records or numbers stored as strings.
What about very large files?
They work, but formatting a multi-megabyte file produces something no one can read. For anything that size you want a query rather than an indent.
Got a wall of JSON to make sense of?