Guide
Common JSON Syntax Errors and How to Fix Them
Most JSON parse errors come from a small set of syntax issues. Learn how to recognize and fix them quickly.
Related tools
JSON is stricter than JavaScript object literals
A common source of JSON errors is treating JSON like JavaScript. JSON has a smaller grammar: object keys must be quoted, strings must use double quotes, comments are not allowed, and trailing commas are invalid.
Frequent mistakes
- Missing comma: every property or array item must be separated from the next one.
- Unquoted key: use "name" instead of name.
- Single quotes: use "value" instead of 'value'.
- Trailing comma: remove the comma after the last object property or array item.
- Comment lines: remove // and /* */ comments before parsing as JSON.
- Broken nesting: check that every { has a matching } and every [ has a matching ].
A practical debugging workflow
Start with the first parser error instead of fixing the whole file at once. A missing comma near the top can create misleading errors later in the document.
After the JSON validates, run it through a formatter. Indentation makes mismatched nesting and unexpected object shapes much easier to see.
FAQ
Why are comments invalid in JSON?
The JSON standard does not include comments. Some tools accept JSON-like formats, but standard JSON parsers reject them.
Why does the parser point after the real mistake?
Parsers often discover an error only when they reach the next token that does not fit the grammar.