Common JSON Errors & How to Fix Them
A complete guide to every common JSON syntax error. Each entry includes the exact error message, why it happens, and a before/after example showing how to fix invalid JSON. Use the JSON validator to detect and locate errors automatically.
Trailing Comma
SyntaxError: Unexpected token } in JSONJSON does not allow a comma after the last element in an object or array. This is the single most common JSON syntax error because JavaScript allows trailing.
cancel Invalid JSON
{
"name": "Alice",
"age": 30,
}check_circle Fixed JSON
{
"name": "Alice",
"age": 30
}Fix: Remove the comma after the last key-value pair before the closing } or ].
Unquoted Object Keys
SyntaxError: Unexpected token n in JSONAll JSON object keys must be enclosed in double quotes. JavaScript object literals allow unquoted keys, but JSON requires every key to be a quoted string.
cancel Invalid JSON
{
name: "Alice",
age: 30
}check_circle Fixed JSON
{
"name": "Alice",
"age": 30
}Fix: Wrap every object key in double quotes.
Single-Quoted Strings
SyntaxError: Unexpected token ' in JSONJSON requires double quotes (") for all strings — both keys and values. Single quotes are a JavaScript convention not valid in JSON.
cancel Invalid JSON
{
'name': 'Alice',
'city': 'London'
}check_circle Fixed JSON
{
"name": "Alice",
"city": "London"
}Fix: Replace all single quotes with double quotes.
undefined, NaN, or Infinity Values
SyntaxError: Unexpected token u in JSONJSON only supports six data types: string, number, object, array, boolean, and null.
cancel Invalid JSON
{
"value": undefined,
"score": NaN,
"limit": Infinity
}check_circle Fixed JSON
{
"value": null,
"score": null,
"limit": null
}Fix: Replace undefined, NaN, and Infinity with null or a numeric literal.
Unquoted String Values
SyntaxError: Unexpected token A in JSONString values in JSON must be wrapped in double quotes. Bare words are only valid for the keywords true, false, and null.
cancel Invalid JSON
{
"status": active,
"role": admin
}check_circle Fixed JSON
{
"status": "active",
"role": "admin"
}Fix: Wrap all string values in double quotes. Only true, false, and null can be unquoted.
Missing Comma Between Properties
SyntaxError: Unexpected string in JSONEvery property in a JSON object and every element in a JSON array must be separated by a comma.
cancel Invalid JSON
{
"name": "Alice"
"age": 30
}check_circle Fixed JSON
{
"name": "Alice",
"age": 30
}Fix: Add a comma after every property except the last one.
Unescaped Special Characters
SyntaxError: Bad escaped character in JSONCertain characters inside JSON strings must be escaped with a backslash: double quote (\"), backslash (\\), and control characters like newline (\n) and tab (\t).
cancel Invalid JSON
{
"path": "C:\Users\Alice",
"message": "He said "hello""
}check_circle Fixed JSON
{
"path": "C:\\Users\\Alice",
"message": "He said \"hello\""
}Fix: Escape backslashes as \\ and double quotes inside strings as \".
JSON Linter vs JSON Validator
A JSON linter and a JSON validator refer to the same type of tool — both check whether JSON conforms to the RFC 8259 specification. "Linter" is borrowed from code quality tools; "validator" is the more formal term used in the JSON ecosystem. Both catch the same json syntax errors listed on this page.
If you need to validate json schema (checking whether values conform to a JSON Schema definition, not just whether the JSON is well-formed), you need a JSON Schema validator — a different tool that works on top of a valid JSON string.
Use the free JSON validator arrow_forwardRelated JSON Tools
JSON Validator
Detect and locate JSON syntax errors automatically.
JSON Formatter
Beautify JSON to make errors easier to spot visually.
JSON Examples
Valid JSON examples by use case — objects, arrays, nested structures.
JSON Tutorial
Complete beginner guide to JSON syntax and structure.
Part of the JSON Toolkit
Explore All JSON Tools
Free online tools for every JSON task — format, validate, convert, compare, and more.
Comments in JSON
SyntaxError: Unexpected token / in JSONStandard JSON does not support comments. This is by design — JSON is a data-interchange format, not a config language.
cancel Invalid JSON
{ // user profile "name": "Alice", "age": 30 /* in years */ }check_circle Fixed JSON
{ "name": "Alice", "age": 30 }Fix: Remove all comments. For config files that need comments, use JSONC or JSON5 format instead.