flashman
← All guides

JSON formatting and validation: a practical guide

How to pretty-print, minify, and validate JSON for APIs, configs, and logs—without leaking data.

2026-06-01 · 5 min read

JSON is the lingua franca of web APIs and many configuration systems. Small syntax errors—a trailing comma, a single quote instead of double—break parsers and deployments. Formatting tools help you see structure; validators catch mistakes before they reach production.

When to format vs minify

Pretty-print for humans: code review, documentation, support tickets. Minify for machines: embedding in scripts, reducing payload size over the wire, or storing compact blobs. Always keep a formatted source of truth in version control when humans edit the file.

Common mistakes

A validator that reports line-aware errors saves hours compared to guessing from a generic parse failure.

  • Trailing commas after the last array or object element
  • Unquoted keys (valid in JavaScript, invalid in strict JSON)
  • NaN and Infinity (not standard JSON)
  • Duplicate keys where the last value silently wins

Privacy tip

API responses may contain PII or secrets. Use client-side formatters like Flashman when you cannot paste data into unknown SaaS tools. Clear the tab when finished on shared machines.

Try these tools