Invalid JSON is one of the most frustrating errors in development. This guide covers the 8 most common JSON errors, shows you exactly how to identify them, and gives you step-by-step fixes.
JSON (JavaScript Object Notation) has a strict specification defined by RFC 8259. Any deviation from this spec makes the JSON invalid. The problem is that many developers write JSON-like structures that work in JavaScript but fail strict JSON parsing.
{
"name": "Alice",
"age": 30,
}{
"name": "Alice",
"age": 30
}JSON strictly forbids trailing commas. Unlike JavaScript, you cannot leave a comma after the last property.
{
'name': 'Alice',
'age': 30
}{
"name": "Alice",
"age": 30
}JSON requires double quotes for strings and object keys. Single quotes are valid in JavaScript but not in JSON.
{
name: "Alice",
age: 30
}{
"name": "Alice",
"age": 30
}All object keys in JSON must be wrapped in double quotes. Unquoted keys are valid in JavaScript objects but invalid in JSON.
{
"name": "Alice",
"score": undefined,
"rating": NaN
}{
"name": "Alice",
"score": null,
"rating": null
}JSON does not support undefined or NaN. Use null instead, or omit the property entirely.
{
"bio": "Line one
Line two"
}{
"bio": "Line one\nLine two"
}Control characters like newlines must be escaped with a backslash. Use \n for newlines, \t for tabs, etc.
{
"name": "Alice"
}{
"name": "Alice"
}Some editors add an invisible BOM character at the start of UTF-8 files. This breaks JSON parsers. Save the file without BOM.
{
"path": "C:\Users\Alice\file.json"
}{
"path": "C:\\Users\\Alice\\file.json"
}Backslashes must be escaped as \\ in JSON strings. A single backslash is interpreted as an escape character.
When JSON.parse() throws an error, the message usually includes the line and column number. But reading these messages takes practice.
SyntaxError: Unexpected token \u007D in JSON at position 42
This means the parser hit a closing brace } where it expected something else — usually a value after a trailing comma. Count characters from the start, or use an online validator that highlights the exact position.
Paste your JSON into the validator
Read the error message and note the line/column
Check the 8 common errors above — does it match?
Apply the fix
Validate again until it passes
It means the parser found a character it did not expect at that position. Common causes include trailing commas, single quotes, or unquoted keys.
No, standard JSON does not support comments. Use JSON5 if you need comments, or add a separate '_comment' field.
JavaScript objects allow features that JSON does not: single quotes, unquoted keys, trailing commas, undefined, NaN, and comments.
Paste your JSON into a validator. The error message usually includes the line and column number where parsing failed.
Use an online JSON validator that shows the exact error location. Fix one error at a time, then re-validate.
Paste your broken JSON into our free validator. Get instant error detection and clear fix instructions.
Try JSON Formatter Online →
Error 4 — Comments in JSON
Standard JSON does not support comments. If you need comments, use JSON5 or store them in a separate field.