JSON Validator
Check whether your JSON is valid and find the exact error.
JSON parsers are unforgiving by design, which is a feature until you are staring at “Unexpected token” and cannot see anything wrong. A validator points at the exact character that broke it.
Validating JSON
- Paste your JSON into the box above.
- Validate it.
- If it fails, read the position reported in the error.
- Look just before that point — the real mistake is usually one character earlier.
- Fix and revalidate until it passes.
The four mistakes behind almost every failure
A trailing comma after the last item in an object or array. Legal in JavaScript, illegal in JSON, and by far the most common cause.
Single quotes instead of double. JSON requires double quotes around every key and every string value, with no exceptions. Then there are unquoted keys, which JavaScript object literals allow and JSON does not. And finally comments — JSON has no comment syntax at all, so a // line will always fail. Between them these four account for the overwhelming majority of invalid JSON.
Valid or not
| Example | Verdict | Why |
|---|---|---|
| {"a": 1,} | Invalid | Trailing comma |
| {'a': 1} | Invalid | Single quotes |
| {a: 1} | Invalid | Unquoted key |
| {"a": 1} // note | Invalid | JSON has no comments |
| {"a": undefined} | Invalid | undefined is not a JSON value |
| {"a": null} | Valid | null is a JSON value |
Why the error position can mislead
Parsers report where they gave up, not where you went wrong. Forget a closing brace halfway down a file and the parser will happily continue until it hits something impossible, often hundreds of lines later.
So treat the reported position as a starting point and work backwards. Validating a formatted version of the document rather than a single-line blob makes this dramatically easier, because the indentation shows you where a block failed to close.
JSON validation questions
Why is my JSON invalid when it works in JavaScript?
Because JavaScript object literals are far more permissive. JSON forbids trailing commas, single quotes, unquoted keys, comments and undefined. Any of those will parse in a browser console and fail in a JSON parser.
Can JSON contain comments?
No. The specification has no comment syntax. Some tools accept a relaxed variant such as JSON5 or JSONC, but standard parsers will reject them. If you need documentation, add a regular key holding a description string.
What is the difference between validating and formatting?
Validating checks whether the text is legal JSON. Formatting re-indents it for readability. A document must be valid before it can be formatted, so a formatter that refuses to run is telling you something.
Does JSON allow duplicate keys?
The specification does not forbid them, but behaviour is undefined and most parsers silently keep the last value. Avoid them entirely — the resulting bugs are very hard to trace.
Is my data sent to a server?
Yes. Your JSON is sent to the server for validation, but it is not stored. See our privacy policy for details.