JSON Formatter & Validator
Paste JSON to pretty-print, minify, or validate it. If it's invalid, you'll see the exact parse error.
How it works
The text is parsed with your browser's built-in JSON parser and written back out. If parsing fails, nothing is output and the parser's own error message is shown. If it succeeds, Pretty-print indents with two spaces and Minify removes all spacing. Both keep the data identical.
Example
The input {"a":1,"b":[true,null]} pretty-prints to:
{
"a": 1,
"b": [
true,
null
]
}What re-writing can change
- Strict JSON only: comments, trailing commas and single quotes are rejected rather than repaired.
- If an object repeats a key, only the last value survives.
- Integers beyond 9,007,199,254,740,991 lose precision, because the parser reads numbers as JavaScript numbers.
- Error wording differs a little between browsers, so the same mistake may be described differently.
Pretty-print vs. minify
Pretty-printing adds indentation and line breaks to make JSON readable for humans. Minifying strips all unnecessary whitespace to make the file as small as possible — useful when sending JSON over a network where every byte counts, but hard to read.
Handy ways to use the output
Pretty-print before comparing two versions of a file line by line, for example in the Text Diff Checker, because both copies then use the same layout. Minify before pasting JSON into a single-line field such as a config value or a URL parameter.
Common JSON mistakes this catches
- Trailing commas after the last item in an object or array
- Using single quotes instead of double quotes for strings
- Missing a closing brace, bracket, or quote
- Unquoted object keys
Guide
- JSON Parse Errors: Common Mistakes and Fixes — The mistakes behind most "invalid JSON" errors, with before-and-after fixes and how to read where the parser gave up.
Edge cases, with real input
Pretty-print and Minify both parse the text and write it back out, so they show what a program would actually read. Minify turns { "a" : 1 , "b" : [ true , null ] } into {"a":1,"b":[true,null]}. Numbers are rewritten as numbers, so [1.0, 1e3, 0.10] becomes [1,1000,0.1]. Empty containers stay compact, and {"a":{}} pretty-prints as an object holding an empty object on one line.
Three results surprise people. A repeated key keeps only its last value, so {"a":1,"a":2} becomes {"a":2}. A key that looks like a whole number moves to the front of its object, so {"b":1,"2":2,"1":3} comes out as {"1":3,"2":2,"b":1}, because that is how JavaScript orders object keys. And 12345678901234567890 is written back as 12345678901234567000, since the last digits cannot be held exactly; keep IDs that long as strings.
A missing quote, an unquoted key or a trailing comma is reported with your browser's own wording and, in current browsers, a line and column position. Fix the first reported problem and format again, since later ones are often caused by it.
Frequently asked questions
Why does it say my JSON is invalid when it looks fine?
A common cause is a trailing comma after the last item in an object or array, or using single quotes instead of double quotes — both are valid in JavaScript object literals but not in strict JSON.
Is my data sent anywhere?
No — parsing and formatting happen entirely in your browser using JavaScript's built-in JSON support. Nothing is uploaded.