Skip to main content

2026-05-31 · 1 min read

Format and minify JSON without surprises

Use pretty-print for review and minify for transport—know when each helps.

JSONAPIconfig

Key takeaways

  • Pretty JSON helps humans; minified JSON saves bytes.
  • Formatting does not fix semantic errors—validate when it matters.

When to format vs minify

Use Format when reviewing diffs, onboarding teammates, or debugging nested structures.

Use Minify when sending payloads where bandwidth or line noise matters.

What to do next

If JSON is generated from templates, run JSON Validator after edits to catch trailing commas or bad types.

If you bounce between YAML and JSON, YAML ⇄ JSON can help—but keep a single source of truth for production.

Trailing commas vs JSON.parse

JavaScript object literals allow trailing commas; JSON.parse does not. If a teammate copied a snippet from a .ts file, Formatter will fail on the last property comma—remove it rather than wrapping in eval.

Minify after you confirm the payload is valid. Minifying invalid JSON hides the line number that Validator would have shown.

FAQ

Will formatting change data meaning?

Whitespace changes only; key order may differ by implementation but parsed objects should be equivalent.

When should I minify?

For network payloads, logs you must ship, or storage where size matters.