- Home
- Tools
- Developer Tools
- JSON Formatter
- JSON Validator
JSON Validator
Check whether a text is valid JSON. If it is not, you get the line, the column and the reason of the first mistake.
Nothing to paste? , or .
Verdict
Paste or type JSON in the box. The verdict appears here as you type.
The mistakes behind "invalid JSON"
JSON has a small, strict grammar, and a text either follows it or does not. Nearly every text that fails does so on one of the mistakes below. The last column is what this validator says about the example.
| Mistake | Example | What the validator reports |
|---|---|---|
| A comma after the last item | {"a": 1, "b": 2,} | Line 1, column 16. Trailing comma. JSON does not allow a comma after the last value. |
| Single quotes | {'a': 1} | Line 1, column 2. Single quotes are not allowed. Strings and keys need double quotes. |
| A key without quotes | {a: 1} | Line 1, column 2. Keys must be in double quotes: write "a" instead of a. |
| A comment | {"a": 1} // note | Line 1, column 10. JSON has no comments. Remove this one. |
| NaN, Infinity or undefined | {"a": NaN} | Line 1, column 7. NaN is not allowed in JSON. Use null, or put it in quotes. |
| A missing comma | {"a": 1 "b": 2} | Line 1, column 8. A comma is missing here, between two values. |
| A bracket that is never closed | {"a": [1, 2} | Line 1, column 12. This array was opened with [, so it has to be closed with ], not }. |
| A number with a leading zero | {"a": 007} | Line 1, column 7. Numbers cannot start with a zero. Write 7 instead of 007, or put the value in quotes if the zeros matter. |
| Python's True, False or None | {"a": True} | Line 1, column 7. JSON writes this in lowercase: true, not True. |
Only the first mistake is reported, because everything after it may be a consequence of it. Fix it and the next one shows up. For mistakes that can only mean one thing, the Repair button under the message does the fixing.
Where the position points
The line and column are those of the first character the grammar cannot accept, with two exceptions that send you straight to the place that needs editing. A missing comma is reported where the comma belongs, right after the value in front of it, and not at the start of the next line. A trailing comma is reported at the comma, not at the bracket behind it.
Columns count characters, so an emoji or a letter with an accent is one column.
Valid does not mean correct
A validator checks the grammar and nothing else. {"age": "forty"} is valid JSON. Whether age should have been a number is for the program that reads it to decide, or for a JSON Schema.
Three things pass and still deserve a second look. You get a note for the first two.
- The same key twice in one object. It is allowed, but most parsers keep only the last value.
- A number with more digits than a 64-bit float holds, such as a 19-digit ID. It is valid, and JavaScript rounds it.
- A bare value.
42,"hello"andnullare complete JSON texts. The first JSON specification only allowed an object or an array at the top, and some old parsers still insist on one.
The JSON formatter page has the rules of JSON in full, what Repair fixes, and why large numbers need care.