Dev Tools
JSON Formatter & Validator
Clean up messy JSON, minify it for production, or just check whether it's actually valid.
Result
–
Runs entirely in your browser. Nothing you paste is sent anywhere.
Learn about JSON validation
What "valid JSON" actually requires
JSON is stricter than a JavaScript object literal, even though it looks almost identical. Keys and string values need double quotes, not single. Trailing commas aren't allowed. Comments aren't allowed. Unquoted keys aren't allowed. A lot of this is exactly why validation is useful: something can run fine in a JavaScript console while still failing JSON.parse(), because the console is more forgiving than the actual spec.
Reading a validation error
Most errors point to the exact character where parsing broke, often with a message like "Unexpected token" and a position number. That position counts from the very start of the text, including whitespace, so it's worth counting carefully rather than guessing. Common culprits are a trailing comma before a closing bracket, a missing comma between entries, or an unclosed bracket somewhere earlier in the document.
Common questions
Why does my JSON work fine in JavaScript but fail here? JavaScript object literals are more permissive than JSON. Modern JS often allows trailing commas, unquoted keys, and single-quoted strings, none of which the JSON spec permits. Something can be valid JavaScript without being valid JSON.
What's the difference between formatting and minifying? Formatting adds whitespace and indentation to make the structure easy to read. Minifying strips that whitespace out to reduce file size for production. Both represent exactly the same data.
Does JSON support comments? No, the spec has no comment syntax at all. Some tools support an extension like JSON5 or JSONC that adds comments, but that's not standard JSON and won't parse with a strict JSON.parse().