How to Format and Validate JSON
Formatted and minified at once — and when it's broken, how to translate the parser's error into the character that actually caused it.
Formatted, minified, and the error if there is one
Paste JSON and you get it indented and minified together. If it doesn't parse, both boxes show the parser's own message with a position — not a bare "invalid".
Everything runs in your browser. Nothing is uploaded, which matters more than it sounds given what people paste into JSON tools.
Formatted
Two-space indent. If it does not parse, you get the parser error and position instead.
{
"name": "Ada",
"active": true,
"score": 9.5,
"langs": [
"ts",
"py"
],
"meta": {
"id": 42,
"tags": null
}
}Minified
All whitespace between tokens removed. Same data, fewer bytes.
{"name":"Ada","active":true,"score":9.5,"langs":["ts","py"],"meta":{"id":42,"tags":null}}Open the JSON Formatter & Validator on its own page to bookmark or share it.
How to read the error
This is the part worth knowing, because parser messages are precise and slightly misleading at the same time.
Paste {"a":1,} and you get:
Invalid JSON — Expected double-quoted property name in JSON at position 7 (line 1 column 8)
Two things to understand:
It tells you what it expected, not what you did wrong. After a comma, the parser is looking for another key — so a trailing comma reports as a missing property name. Once you know that translation, "expected double-quoted property name" means "you left a comma on the end."
The position is where it gave up, not where you erred. Position 7 is the }. The actual mistake is the comma at position 6. Look at the character before the one it names.
The five things that break JSON
In rough order of how often they turn up:
{"a":1,} | Trailing comma — more common than everything else combined |
{'a':1} | Single quotes — strings need double |
{a:1} | Unquoted key |
// comment | Comments aren't JSON |
| Raw line break in a string | Must be escaped as \n |
Notice what these have in common: all five are legal JavaScript. That's exactly why they get typed by accident. JSON looks like a JavaScript object literal and is far stricter than one.
Minifying never changes your data
Formatted and minified parse to the identical value, so the minified form is safe anywhere the formatted one would have worked.
It isn't a pure whitespace strip, though — minifying re-serialises through the parser exactly as formatting does, so numbers come back in canonical form (see below). What it never does is change what the data means.
Whitespace inside a string is left alone — that's data, not formatting.
Why your number looks different
Paste {"n":1.50,"e":1e3} and you get back:
{
"n": 1.5,
"e": 1000
}
Nothing changed value — only spelling. The parser re-serialises numbers in canonical JSON form.
If the exact original text matters — a version like 1.10, an ID with leading zeros, a value beyond what a double can hold precisely — it should have been a string in the first place. That's not this tool being lossy; that's JSON numbers being numbers.
What JSON doesn't have
Worth keeping straight, because these are the things that come up when generating JSON from another language:
- No
undefined,NaN, orInfinity - No dates — they're strings by convention, usually ISO 8601
- No comments
- Numbers: no leading
+, no leading zeros, no hex - The top level can be any value, not just an object or array
Key order
Keys come back in the order they went in. JSON objects are formally unordered and most parsers preserve insertion order in practice.
If something downstream genuinely depends on key order, that's worth knowing about that thing, because the specification doesn't promise it to you.
A word about pasting
This runs entirely in your browser — no upload, no server, nothing stored.
Not every online JSON tool works that way, and the things that get pasted into them are frequently production API responses, configuration files, and credentials that were sitting inside them. Worth a habit of checking before pasting, wherever you happen to be.
Print the JSON debugging sheet if you're the person on your team who keeps getting handed a broken config file.
Free tool
JSON Formatter & ValidatorPaste JSON and get it indented and minified at once - and if it is broken, the parser's own error with the line and column.
Open the tool →Enjoyed this? Get the next one.
New articles straight to your inbox. No spam, ever.
Keep reading
How DNS propagation time is estimated
Learn what DNS propagation time really means, how to estimate it from TTL and cache windows, and what the calculator can’t know.
Aug 4, 2026 · 5 min read
How Big Can I Print This Photo?
300 dpi isn't a standard — it's the answer for arm's length. At ten feet, a 24 MP file covers seventeen feet of wall.
Aug 3, 2026 · 4 min read
How Far Should You Sit From Your TV?
Two different questions with two different answers — and at 4K they stopped agreeing. At nine feet you can go from a 69-inch screen to a 138-inch one.
Aug 3, 2026 · 4 min read