How to Format JSON (and Why It Matters)
A practical guide to beautifying, indenting, and minifying JSON — and when to use each, with tips for debugging messy API responses.
JSON is everywhere — APIs, config files, logs — but raw JSON is often a single unreadable line. Formatting (also called beautifying or pretty-printing) adds indentation and line breaks so humans can actually read it.
Beautify vs. minify
There are two opposite operations:
- Beautify adds whitespace for readability. Use it while debugging or reviewing data.
- Minify strips all whitespace to shrink payloads. Use it in production to save bandwidth.
Try the JSON Formatter to beautify, and the JSON Minifier to compress.
Choosing an indentation
Two spaces is the most common convention and what most editors default to. Four spaces reads well in documentation, and tabs respect each developer's editor settings. Pick one and stay consistent — a stable format makes diffs in version control far easier to read.
Fixing messy JSON
If your JSON won't parse, it usually has one of a few problems: a trailing comma, single quotes instead of double quotes, or an unquoted key. The JSON Fixer repairs these automatically, and the JSON Validator pinpoints the exact line and column of a syntax error.
A note on privacy
Every tool on JSONPost runs entirely in your browser. Your data is never uploaded, so it's safe to format production payloads and private responses.
Keep reading
Validating JSON with JSON Schema
Learn how JSON Schema works, how to generate a schema from sample data, and how to validate documents with clear, path-based error messages.
JSON vs JSON5 vs JSONC — What's the Difference?
Comments, trailing commas, and unquoted keys — understand JSON5 and JSONC, where each is used, and how to convert them to strict JSON.
Safely Parsing Untrusted JSON in JavaScript
Parse untrusted JSON in JavaScript without crashing or opening security holes — try/catch, revivers, prototype pollution, schema validation, size and depth limits.