JSON is everywhere a developer looks — API responses, configuration files, log lines, browser storage. It is simple by design, but that simplicity hides a handful of rules that, when broken, produce parser errors with unhelpful messages. This guide explains what formatting and validation actually do, the mistakes that cause most JSON errors, and how to make a wall of minified text readable in seconds.
What "formatting" JSON means
Formatting (also called beautifying or pretty-printing) does not change the data — it only changes the whitespace. A formatter parses the JSON into a structure, then re-serialises it with consistent indentation and line breaks so the nesting is visible. Minifying is the reverse: it strips every optional space and newline to make the payload as small as possible for transport. The data is identical either way; only readability and size change.
The errors that break JSON most often
- Trailing commas — a comma after the last item in an object or array is invalid JSON, even though many programming languages allow it.
- Single quotes — JSON strings and keys must use double quotes. Single quotes are a frequent copy-from-JavaScript mistake.
- Unquoted keys — every object key must be a quoted string; bare identifiers are not allowed.
- Comments — JSON has no comment syntax. // and /* */ will fail.
- Unescaped characters — literal newlines or unescaped quotes inside a string break parsing.
A validator catches these by attempting to parse the text and reporting the first position where parsing fails, which is far faster than scanning by eye.
How to read a large payload quickly
When you paste a minified response, format it first so the structure appears, then read top-down: the outermost braces tell you whether you have an object or an array, and the indentation reveals how deep the nesting goes. For a quick sanity check, formatting also instantly reveals an invalid payload — if it will not format, it will not parse in your code either.
A note on security
JSON you are debugging often contains real data — tokens, personal details, internal IDs. Prefer a formatter that runs entirely in your browser so the payload is never uploaded. That way you can safely format a production response without it leaving your machine.