ToolzVerse

Blog

JSON formatting for developers: beyond just pretty-printing

ToolzVerse Team · July 28, 2026

Every developer has pasted an unreadable, single-line JSON blob into a formatter and hit "beautify." That's the easy 20% of working with JSON. The other 80% is validation, debugging malformed payloads, and making sense of deeply nested structures.

Pretty-printing is table stakes

Indentation and line breaks matter, but the real value of a JSON formatter is what happens when the JSON is invalid — which is most of the time you actually need one. A good formatter should:

  • Point to the exact line and character where parsing failed, not just say "invalid JSON"
  • Distinguish between common failure modes: trailing commas, unquoted keys, single quotes instead of double quotes, missing closing brackets
  • Preserve your original data on failure instead of clearing the input

If a tool just says "Error" with no location, you're back to squinting at the raw text.

Common JSON mistakes worth knowing by sight

Recognizing these patterns speeds up debugging more than any tool:

  1. Trailing commas — valid in JS object literals, invalid in JSON. {"a": 1, "b": 2,} fails.
  2. Single-quoted strings — JSON requires double quotes. {'a': 1} is not valid JSON even though it's valid-looking JS.
  3. Unquoted keys{a: 1} is JS shorthand, not JSON.
  4. NaN, undefined, and comments — none of these exist in the JSON spec, even though they parse fine in a .js file.
  5. Duplicate keys — technically parses in most implementations (last one wins), but it's a silent bug generator. Worth flagging even though it's not strictly invalid.

Most of these come from developers copy-pasting a JS object literal and assuming it's the same thing as JSON. It isn't.

Formatting for diffing and code review

If you're committing JSON config files, consistent formatting matters for clean diffs. Pick one convention and stick to it:

  • 2-space indentation is the de facto standard for JSON in most ecosystems (package.json, tsconfig.json, etc.)
  • Sort object keys alphabetically if the file is hand-edited by multiple people — it turns "who changed what" into an obvious diff instead of noise from key reordering
  • Strip trailing whitespace — some formatters leave it, and it shows up as phantom diff lines

A faster loop

For quick one-off checks — validating an API response, reformatting a config snippet, minifying JSON before pasting it somewhere with a size limit — JSON Formatter does all of the above entirely in your browser: paste, get pinpointed error locations on invalid input, toggle between pretty and minified, no request ever leaves your machine. Useful when the JSON contains anything you'd rather not paste into a random online tool that logs requests server-side.