The complete guide to JSON formatting and validation
Why JSON formatting matters
JSON is the backbone of modern APIs. But raw JSON from an API response or a log file is often minified into a single line that is impossible to read.
A properly formatted JSON document follows consistent indentation, clear key-value pairs, and no trailing commas. This is not just cosmetic — it helps catch syntax errors early.
Common JSON validation errors
Trailing commas — JSON does not allow a comma after the last element in an object or array
Missing quotes — all object keys must be double-quoted
Unescaped control characters — tabs, newlines, and carriage returns inside strings must be escaped
Single quotes — JSON only accepts double quotes for strings
Comments — JSON has no native comment support, unlike JSONC or YAML
Pretty-printing vs minification
Pretty-printing adds indentation and line breaks for readability. Minification removes all whitespace for smaller payload sizes.
Use pretty-printing during development and debugging. Use minified JSON in production to reduce bandwidth and parse time.
Try it online
The JSON formatter and JSON decoder handle formatting, validation, and minification in one click. For structural comparisons, use the JSON diff tool.