Blog · July 12, 2026 · 8 min read
How to Format and Validate JSON Without the Usual Mistakes
JSON looks simple until a single trailing comma breaks an API call at 2 a.m. Formatting and validating JSON before you paste it into production configs or Postman requests saves time and prevents silent data loss when minifiers or parsers reject invalid input.
The errors that show up most often
- Trailing commas — allowed in modern JavaScript objects, illegal in strict JSON
- Single quotes — JSON strings must use double quotes
- Unquoted keys —
{name: "Ada"}is invalid; keys need quotes - Comments —
//and/* */are not part of the JSON standard - NaN / Infinity / undefined — these are JavaScript values, not JSON
- Smart quotes — curly quotes copied from documents break parsers instantly
Pretty-print vs minify
Pretty-printing adds indentation and line breaks so humans can review nested structures. Use it when reading logs, reviewing API responses, or editing configs by hand.
Minifying removes unnecessary whitespace. Use it when size matters for transport or storage — but only after validation. Minifying invalid JSON still produces invalid JSON; it just becomes harder to spot the mistake.
A short validation checklist
- Paste the payload into a validator before shipping it
- Confirm the root is an object or array, not a bare string unless that is intentional
- Check nested arrays for mixed types if your consumer expects uniformity
- Verify numbers are not quoted unless they must be strings
- After edits, validate again — especially if you removed a property mid-object
Why client-side formatting helps
API responses and config files sometimes contain tokens, emails, or internal IDs. Formatting them on a remote “JSON beautifier” site means uploading that content to someone else’s server. A browser-local formatter keeps the payload on your machine while still giving you clear syntax feedback.
Try it
Use our JSON Formatter to prettify, minify, and validate JSON entirely in your browser.