Top 10 JSON Errors

Common JSON syntax errors and how to fix them

1. Trailing Comma

SyntaxError: Unexpected token

A comma after the last element in an array or object

Wrong

{"name": "John",}

Correct

{"name": "John"}

2. Single Quotes

SyntaxError: Unexpected token '

Using single quotes instead of double quotes for strings

Wrong

{'name': 'John'}

Correct

{"name": "John"}

3. Unquoted Property Names

SyntaxError: Unexpected identifier

Using JavaScript-style unquoted keys in JSON

Wrong

{name: 'John'}

Correct

{"name": "John"}

4. Comments in JSON

SyntaxError: Unexpected token

JSON does not support comments (// or /* */)

Wrong

{"name": "John"} // comment

Correct

{"name": "John"}

5. Trailing Commas in Arrays

SyntaxError: Unexpected token

Comma after the last element of an array

Wrong

["a", "b", "c",]

Correct

["a", "b", "c"]

6. Undefined Values

SyntaxError: Unexpected token u

Using undefined in JSON (it is not a valid JSON value)

Wrong

{"value": undefined}

Correct

{"value": null}

7. Functions as Values

SyntaxError: Unexpected token

Embedding JavaScript functions in JSON

Wrong

{"name": "John", "getName": function() { return this.name }}

Correct

{"name": "John"}

8. Extra Commas in Objects

SyntaxError: Unexpected token }

Comma after the last property in an object

Wrong

{"name": "John",}

Correct

{"name": "John"}

9. BOM Characters

SyntaxError: Unexpected token 

Byte Order Mark (BOM) at the start of a JSON file

Wrong

{"name": "John"}

Correct

{"name": "John"}

10. Missing Bracket or Brace Balance

SyntaxError: Unexpected end of JSON input

An opening or closing bracket/brace does not have a matching pair

Wrong

{"names": ["John", "Jane"]

Correct

{"names": ["John", "Jane"]}

Validate Your JSON

Paste your JSON and our validator will instantly show you any errors with line numbers.

Go to Validator →