How to format and validate JSON

A one-line blob of minified JSON is impossible to read, and a single misplaced comma breaks the whole thing. This guide shows how to pretty-print JSON, how to spot the error when it won't parse, and how to do it without sending your data anywhere.

The fastest way

Paste your JSON into the JSON Formatter. It pretty-prints valid JSON with clean indentation and, if the JSON is invalid, points you at where parsing failed. Read on for the errors you'll hit most.

Pretty-print vs. minify

Formatting adds indentation and newlines so the structure is readable; minifying strips every space to shrink it for transport. They carry the identical data — format while you work, minify before you ship.

{"user":{"name":"Ann","roles":["admin","editor"]}}

{
  "user": {
    "name": "Ann",
    "roles": ["admin", "editor"]
  }
}

The errors that break JSON

Most "invalid JSON" failures come from a short list of mistakes:

Pretty-printing first usually surfaces the bad line immediately.

Comparing two JSON documents

If two payloads should match but don't, a visual diff is faster than reading both. Drop them into the JSON Diff to see exactly which keys and values changed. And if you need the same data as YAML, JSON ⇄ YAML converts between them.

A note on privacy

JSON often contains tokens, customer records, or internal config. The JSON Formatter parses and formats entirely in your browser, so nothing you paste is ever uploaded to a server.

Open the JSON Formatter →

Common questions

What does it mean to validate JSON?

Validating JSON checks that the text is syntactically correct — every brace and bracket is closed, keys are double-quoted strings, values are well-formed, and there are no trailing commas. A validator reports the first position where parsing fails so you can fix it.

What are the most common JSON errors?

Trailing commas after the last item, single quotes instead of double quotes, unquoted keys, missing commas between items, and stray comments (standard JSON has no comments). Pretty-printing the JSON usually makes the offending line obvious.

What is the difference between formatting and minifying?

Formatting (pretty-printing) adds indentation and line breaks so JSON is readable; minifying strips all whitespace to make it as small as possible for transport. Both represent the exact same data.

Is my JSON uploaded when I format it?

No. The JSON is parsed and formatted entirely in your browser, so API responses, tokens, and config files never leave your device.