Minified JSON is hard to read, and a single stray comma can break a whole payload. This guide explains how to check whether JSON is valid, make it readable, and fix the errors that show up most often.
What makes JSON valid
JSON must use double quotes for strings and keys, cannot contain trailing commas, and must wrap objects in curly braces and arrays in square brackets. Comments are not allowed. These rules are stricter than JavaScript object literals, which is why code snippets pasted into a JSON validator so often fail.
If a validator reports an error, it usually points at the line and column of the first unexpected character, so start there and work outward.
Formatting vs. minifying
Formatting (also called pretty-printing) adds indentation and line breaks so the structure is visible at a glance. Minifying strips all unnecessary whitespace to produce the smallest payload for sending over a network. Both represent exactly the same data.
A common workflow is to minify JSON before storing or transmitting it, then format it again whenever you need to read it.
Common syntax mistakes
Trailing commas, single-quoted keys or strings, and unquoted keys are the three most frequent errors. Another classic is forgetting a closing bracket after a deeply nested object. When an error message mentions an unexpected token, check the characters immediately before it.
Going further
Once your JSON is valid, you can convert it to other formats. If you need TypeScript types from a JSON sample, paste it into the JSON to TypeScript tool, or convert between JSON and YAML or CSV with the relevant converters.