How to validate JSON
- Paste the JSON or open a file. Validation runs automatically while you type.
- A green “Valid JSON” message with statistics means the document is correct. Otherwise read the error: it names the line, the column and what was expected there.
- Fix the highlighted line or click Repair, then Format the result to make it easy to read.
Common JSON errors and how to fix them
| Error | Example | Fix |
|---|---|---|
| Trailing comma | [1, 2, ] | Remove the comma before ] or } |
| Single quotes | {'name': 'Ada'} | Use double quotes: {"name": "Ada"} |
| Unquoted key | {name: "Ada"} | Quote the key: {"name": "Ada"} |
| Missing comma | {"a": 1 "b": 2} | Add a comma between the properties |
| Comment | // settings | JSON has no comments – remove them |
| Line break in a string | "line 1⏎line 2" | Write \n instead of a real line break |
| Invalid value | undefined, NaN, True | Use null, a number, true or false |
| Leading zero | {"zip": 01234} | Write 1234, or keep it as text: "01234" |
| Missing bracket | {"a": [1, 2} | Close every [ with ] and every { with } |
What makes JSON valid
JSON is defined in RFC 8259. A valid document follows a few strict rules:
- It contains exactly one top-level value, usually an object
{}or an array[]. - Object members are
"key": valuepairs separated by commas; keys are always strings in double quotes. - Strings use double quotes; inside them only
\" \\ \/ \b \f \n \r \tand\uXXXXescapes are allowed. - Numbers are decimal: no leading zeros, no
+sign, no hexadecimal, noNaNorInfinity. true,falseandnullare written in lowercase.- Spaces, tabs and line breaks are allowed between tokens, but not comments.
Validate JSON on the command line
- Python:
python -m json.tool file.jsonprints the line and column of the first error. - jq:
jq empty file.jsonexits with an error message if the file is invalid. - Node.js:
node -e "JSON.parse(require('fs').readFileSync('file.json', 'utf8'))"
Frequently asked questions
What is the difference between a JSON validator and a JSON linter?
A validator checks whether text follows the JSON syntax. A linter usually also enforces a consistent style. This JSON checker validates strictly against RFC 8259 and, with Format, gives you consistent indentation as well.
Can it validate against a JSON Schema?
This page checks syntax. To describe the expected structure of your data, create a schema from an example document with our JSON Schema generator.
Why is my JSON valid here but rejected by another program?
Programs often expect a specific structure (certain keys or types), a particular encoding such as UTF-8 without a byte order mark, or numbers within a limited range. Syntactically valid JSON can still break such application rules.
Is JSON with comments (JSONC) valid?
No. Standard JSON does not allow comments. Some editors accept them in settings files (JSONC), but APIs and JSON.parse do not. Repair removes comments for you.