JSON is everywhere — APIs, config files, data exports — and it's easy to read when it's neatly formatted and maddening when it's a single minified line or riddled with a stray comma. Formatting makes it readable; validating catches the tiny syntax slips that stop it parsing.
This guide covers how to format (pretty-print) JSON, how to validate it, and the handful of syntax rules behind almost every JSON error.
What you need
- ✓The JSON string you want to tidy or check.
- ✓A JSON formatter/validator (a browser-based one keeps your data private).
- ✓A basic grasp of the rules below — they explain most errors.
Step-by-step
- 1
Paste your JSON into a formatter
Drop the raw or minified JSON into a formatter. It re-indents the structure with consistent spacing so nested objects and arrays become readable — the fastest way to understand an unfamiliar payload.
- 2
Read the validation result
A good formatter validates as it formats, pointing to the line and character of the first error. JSON is strict, so it either parses perfectly or fails at a specific spot — the error location is your clue.
- 3
Fix the common syntax errors
Most failures are: a trailing comma after the last item, single quotes instead of double quotes (JSON requires double), missing quotes around keys, or unmatched brackets/braces. Fix the flagged spot and re-validate.
- 4
Check data types
Confirm strings are quoted, numbers aren't, booleans are true/false lowercase, and there are no comments (standard JSON doesn't allow them). These type slips cause silent bugs even when it parses.
- 5
Minify or copy the clean result
Once it's valid, copy the formatted version for readability, or minify it (strip whitespace) for transport where size matters. Keep a formatted copy for humans and a minified one for machines.
Examples
- A one-line API response of 4,000 characters becomes a clear, indented tree — instantly revealing the nested structure you needed.
- A parse error at 'line 12, column 3' turns out to be a trailing comma after the last array item — the classic JSON mistake.
Tips
- →JSON requires double quotes — single quotes are the number-one beginner error.
- →No trailing commas: the last item in an object or array must not be followed by a comma.
- →Standard JSON has no comments; strip them or use JSON5/JSONC only where supported.
- →Use a browser-based tool so sensitive payloads aren't uploaded anywhere.
- →Keep both a pretty version (for reading) and a minified version (for sending).
Common mistakes
- Single quotes. JSON only allows double quotes around strings and keys.
- Trailing comma. Remove the comma after the last element in an object or array.
- Unquoted keys. Every key must be a double-quoted string.
- Adding comments. Standard JSON doesn't support comments; remove them or use a format that does.
Conclusion
Formatting turns unreadable JSON into a clear structure, and validating catches the small syntax slips — trailing commas, single quotes, unquoted keys — behind almost every error. Use a browser-based tool for privacy, keep both pretty and minified copies, and JSON stops being a headache.