How to beautify and validate JSON
A JSON formatter is the cheapest debugging tool you own. Here is what it should — and should not — try to do for you.
You hit an API, the response looks like one long unreadable string, and you need to find a single value buried in it. A JSON formatter turns that string into something a human can actually scan. It's a 5-second operation that saves real time, every time.
Beautify vs minify
Two operations, one tool. The JSON Formatter does both.
Beautify indents the JSON across multiple lines. Each object key/value pair on its own line, nested objects indented further. The output is bigger but readable.
Minify strips every space and newline. The output is one long string with no extra characters. Useful when you're embedding JSON in a place where size matters (URLs, copy-paste into a CLI command, inline in HTML attributes).
Most of the time you want beautify. Minify is for transport, beautify is for reading.
What "validate" really means
When you paste invalid JSON, a formatter does two things:
- Tries to find the position of the error.
- Tells you why the parse failed.
The common errors:
- Trailing commas.
{"a": 1,}is invalid in standard JSON. Some dialects (JSON5, Hjson) allow them. This tool does not. - Unquoted keys.
{a: 1}is JavaScript object syntax, not JSON. - Single-quoted strings.
{"a": 'b'}— same problem. JSON only allows double quotes. - Comments.
// like thisor/* like this */are not legal JSON.
If you have JSON5 / Hjson with comments and trailing commas, you'll need a JSON5 parser, not this one. For 99% of API responses, the strict version is what you want.
A real-world workflow
You paste a 200-line API response:
- Beautify it.
- Use Ctrl+F (browser find) to locate the field you care about.
- Read the surrounding 2-3 lines for context.
- If you need to share the JSON with a teammate, minify it for paste-into-Slack, beautify it for paste-into-doc.
For larger payloads (think 10MB JSON blobs), most browsers will choke. At that point you want a streaming parser — jq from the command line, or a real text editor with JSON tooling. The browser-based formatter is for the ~1MB sweet spot.
What this tool does not do
- Schema validation. Knowing that JSON is syntactically valid is different from knowing it matches an expected shape. For schema validation, use JSON Schema or
zod. - Diffing two JSON documents. Reformat both, then paste into the Diff Checker — that's the workaround.
- Pretty-printing nested escaped strings. If your JSON contains a string that is itself JSON (e.g.,
{"payload": "{\"a\":1}"}), you'll need to extract that inner string and re-parse it. Or, you know, fix the API so it returns nested JSON properly.
For the everyday "make this readable, is it valid" case — paste, click, done.