JSON validator
Paste JSON and get a straight answer: valid, or the exact line and column it breaks with the likely cause in plain English.
Guide
How to use it
- Paste the JSON that a tool or API rejected.
- Read the status line: valid with a size and key count, or invalid with line, column and the likely cause.
- Fix in the box, it revalidates on every keystroke.
- Valid but ugly? Jump to the formatter for pretty printing and the tree view.
Examples
The four classic errors
[1, 2, 3,]
The trailing comma. Fine in JavaScript source, always invalid in JSON. The validator names it directly.
{'name': 'Sam'}
Single quotes. JSON strings and keys take double quotes only, a find-and-replace usually fixes the lot.
{name: "Sam"}
The unquoted key, usually JSON copied out of JavaScript code rather than from an API.
{"stock": undefined}
undefined and NaN are JavaScript values, not JSON values. Use null and the document parses.
Method
How it works
The verdict comes from the browser's native JSON parser, so it matches what real applications will accept. When parsing fails, the reported position is decoded into a line and column, and a second pass scans your text for the classic mistakes (trailing commas, single quotes, unquoted keys, undefined and NaN) to name the probable cause rather than just point at a character.
Syntax only, no schema checking, and nothing you paste leaves your browser.
FAQ
Frequently asked questions
What does "unexpected token" actually mean?
The parser met a character it could not fit into valid JSON at that point. The position points at where parsing broke, but the real mistake is often just before it, a missing comma or quote on the previous line.
Why is a trailing comma invalid?
JSON's grammar predates the lenient style modern JavaScript allows. A comma after the last item, like [1, 2, 3,], is legal in JS source but always invalid JSON.
Are comments allowed in JSON?
No. Standard JSON has no comment syntax. Config formats that look like JSON with comments (JSONC, JSON5) are different formats; strip comments before validating as JSON.
Can numbers be quoted?
Quoted numbers are valid JSON but they are strings, and code doing arithmetic on them misbehaves. Validity and correctness are different questions.
Is NaN or undefined valid JSON?
No. JSON values are objects, arrays, strings, numbers, true, false and null. Anything else, including undefined, NaN and Infinity, fails, use null instead.
Does validation check my data against a schema?
No, this checks syntax only: whether the text is JSON at all. Schema validation (required fields, types) is a separate job for JSON Schema tooling.
More tools