JSON Parse Error
A JSON parse error means your JSON string is not valid and cannot be parsed. The error message tells you exactly where and why it failed — but the messages can be cryptic. This guide decodes every common JSON parse error and shows you exactly how to fix it.
What Causes a JSON Parse Error?
A JSON parse error is thrown by JSON.parse()when the input string doesn't conform to the JSON specification (RFC 8259). Common causes:
- Single quotes instead of double quotes
- Trailing commas
- Unquoted keys
- Comments
- undefined or NaN values
- Truncated JSON (missing closing brackets)
- Extra data after valid JSON
JSON Parse Error Reference
Unexpected token ',' JSONCause: A trailing comma after the last item in an object or array.
{"name": "Alice", "age": 30,}{"name": "Alice", "age": 30}Expected double-quoted property name in JSONCause: An object key is unquoted or uses single quotes.
{name: "Alice"}{"name": "Alice"}Unexpected token ''' is not valid JSONCause: Single quotes used instead of double quotes.
{'name': 'Alice'}{"name": "Alice"}Unexpected token '/' is not valid JSONCause: A comment (// or /* */) was found in the JSON.
{"name": "Alice" // user}{"name": "Alice"}Unexpected end of JSON inputCause: The JSON string is truncated — a closing brace, bracket, or quote is missing.
{"name": "Alice", "items": [1, 2{"name": "Alice", "items": [1, 2]}Unexpected token 'u' / 'undefined' is not valid JSONCause: The value undefined was included. undefined is a JavaScript concept, not a JSON value type.
{"value": undefined}{"value": null}Unexpected token 'N' / NaN is not valid JSONCause: NaN (Not a Number) was included. NaN is a JavaScript value, not valid in JSON.
{"score": NaN}{"score": null}JSON.parse is not a functionCause: A variable named JSON is shadowing the global JSON object.
const JSON = {};
JSON.parse('{}'); // TypeError// Don't shadow the JSON global
const jsonData = {};
JSON.parse('{}'); // worksHow to Read a JSON Parse Error Message
Error messages differ slightly between environments but always tell you three things:
// Node.js / V8 SyntaxError: Expected ',' or '}' after property value in JSON at position 25 // Firefox SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 3 column 1 of the JSON data // Safari SyntaxError: JSON Parse error: Expected ',' or '}' after property value
- Position / line+column:The character offset or line/column where the parser gave up. The actual error is usually just before this point.
- Expected vs found:"Expected ',' or '}'" means the parser found something unexpected. Look at the character just before the position.
- Unexpected token X:X is the character that shouldn't be there — a single quote, slash, letter like u (undefined), N (NaN), etc.
Fix Your JSON Parse Error Now
Paste your JSON into the free validator — get the exact line, character, and error type instantly.
Validate JSON Free