In this article
Why JSON is so strict
JSON looks like JavaScript, but its rules are much stricter so that every program in every language reads it the same way. Things JavaScript tolerates – trailing commas, single quotes, comments – are errors in JSON. The JSON Validator checks against the official standard (RFC 8259) and points to the line and column of the problem.
The usual suspects
| Mistake | Broken | Fixed |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ali'} | {"name": "Ali"} |
| Unquoted key | {name: "Ali"} | {"name": "Ali"} |
| Comment | {"a": 1 // note} | Remove the comment |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Unescaped quote in text | {"q": "He said "hi""} | {"q": "He said \"hi\""} |
| Special values | {"x": NaN, "y": undefined} | Use null or a number |
| Leading zero | {"code": 007} | {"code": "007"} (as text) |
Reading the error position
The error is usually at or just before the position reported. If the validator says “line 14, column 3”, look at the end of line 13 too – a missing comma there only becomes a problem when the next line starts. For a missing closing bracket, the error may appear at the very end of the file; count your opening and closing brackets in the formatted version.
Duplicate keys: the silent bug
JSON like {"price": 10, "price": 12} is accepted by many parsers, which quietly keep the last value. That can cause bugs that are very hard to track down – a config setting that “does not work” because it is overridden further down. The validator warns about duplicate keys that other tools ignore.
Copy-paste traps
- Curly quotes: word processors and chat apps change
"into “ and ”. JSON only accepts straight quotes. - Invisible characters: non-breaking spaces and byte-order marks from documents. Clean them with Remove Extra Spaces.
- Half a response: logs and consoles sometimes cut long output. If the error is “unexpected end”, check that you copied everything.
How to validate
- Paste your JSON into the JSON Validator.
- Read the result: valid, or an error with line and column.
- Fix and re-check. For valid JSON, the summary shows type, number of keys, nesting depth and size.
- Format it neatly with the JSON Formatter.
Config files that allow comments
Some tools use JSON-like formats that do allow comments or trailing commas – such as VS Code settings (JSONC) or JSON5. Those files are not strict JSON, so a strict validator will complain. If a tool’s documentation says comments are allowed, trust that tool; if the file is sent to an API, use strict JSON.
Private checking
Configuration files often contain passwords and keys. Validation happens in your browser, and nothing is uploaded.