How to format and validate JSON
A one-line blob of minified JSON is impossible to read, and a single misplaced comma breaks the whole thing. This guide shows how to pretty-print JSON, how to spot the error when it won't parse, and how to do it without sending your data anywhere.
The fastest way
Paste your JSON into the JSON Formatter. It pretty-prints valid JSON with clean indentation and, if the JSON is invalid, points you at where parsing failed. Read on for the errors you'll hit most.
Pretty-print vs. minify
Formatting adds indentation and newlines so the structure is readable; minifying strips every space to shrink it for transport. They carry the identical data — format while you work, minify before you ship.
{"user":{"name":"Ann","roles":["admin","editor"]}}
{
"user": {
"name": "Ann",
"roles": ["admin", "editor"]
}
}
The errors that break JSON
Most "invalid JSON" failures come from a short list of mistakes:
- A trailing comma after the last item in an object or array.
- Single quotes — JSON requires double quotes on strings and keys.
- An unquoted key (
{name: "Ann"}instead of{"name": "Ann"}). - A missing comma between two items.
- Comments — standard JSON doesn't allow them.
Pretty-printing first usually surfaces the bad line immediately.
Comparing two JSON documents
If two payloads should match but don't, a visual diff is faster than reading both. Drop them into the JSON Diff to see exactly which keys and values changed. And if you need the same data as YAML, JSON ⇄ YAML converts between them.
A note on privacy
JSON often contains tokens, customer records, or internal config. The JSON Formatter parses and formats entirely in your browser, so nothing you paste is ever uploaded to a server.