{}JSON-Validator.net
Troubleshooting · 6 min read

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
Find the exact error location
Paste your JSON into the validator — it shows the exact line and character.
Validate Now

JSON Parse Error Reference

Unexpected token ',' JSON

Cause: A trailing comma after the last item in an object or array.

Causes error
{"name": "Alice", "age": 30,}
Fixed
{"name": "Alice", "age": 30}
Fix: Remove the comma after the last property or element.
Expected double-quoted property name in JSON

Cause: An object key is unquoted or uses single quotes.

Causes error
{name: "Alice"}
Fixed
{"name": "Alice"}
Fix: Wrap all object keys in double quotes.
Unexpected token ''' is not valid JSON

Cause: Single quotes used instead of double quotes.

Causes error
{'name': 'Alice'}
Fixed
{"name": "Alice"}
Fix: Replace all single quote string delimiters with double quotes.
Unexpected token '/' is not valid JSON

Cause: A comment (// or /* */) was found in the JSON.

Causes error
{"name": "Alice" // user}
Fixed
{"name": "Alice"}
Fix: Remove all comments from the JSON string.
Unexpected end of JSON input

Cause: The JSON string is truncated — a closing brace, bracket, or quote is missing.

Causes error
{"name": "Alice", "items": [1, 2
Fixed
{"name": "Alice", "items": [1, 2]}
Fix: Add the missing closing characters. Paste into the validator to find the exact position.
Unexpected token 'u' / 'undefined' is not valid JSON

Cause: The value undefined was included. undefined is a JavaScript concept, not a JSON value type.

Causes error
{"value": undefined}
Fixed
{"value": null}
Fix: Replace undefined with null, or omit the key entirely.
Unexpected token 'N' / NaN is not valid JSON

Cause: NaN (Not a Number) was included. NaN is a JavaScript value, not valid in JSON.

Causes error
{"score": NaN}
Fixed
{"score": null}
Fix: Replace NaN with null or a valid number.
JSON.parse is not a function

Cause: A variable named JSON is shadowing the global JSON object.

Causes error
const JSON = {};
JSON.parse('{}'); // TypeError
Fixed
// Don't shadow the JSON global
const jsonData = {};
JSON.parse('{}'); // works
Fix: Rename your variable — never use JSON as a variable name in JavaScript.

How 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

Related Guides