</>
ValidateHTML

Unexpected Token in JSON

An unexpected token error means the JSON parser encountered a character it didn't expect at a specific position. This is the most common JSON error and usually comes from trailing commas, single quotes instead of double quotes, unquoted property names, or comments in the JSON.

Why It Matters

The entire JSON document fails to parse. APIs return 400 errors, config files break, and applications crash at startup. A single misplaced character makes the whole document unreadable.

Common Causes

  • Pasting a JavaScript object literal into a .json file, which carries over single quotes, unquoted keys, or a trailing comma.
  • Leaving a // or /* */ comment in a config file that a strict JSON parser then rejects.
  • A stray or missing character (an extra comma, a smart quote pasted from a document) sitting at the position the parser reports.

Code Examples

Invalid JSON
{
  "name": "John",
  "age": 30,
  'email': "john@example.com",
  "active": true,
}
Valid JSON
{
  "name": "John",
  "age": 30,
  "email": "john@example.com",
  "active": true
}

How to Fix

  • 1Replace single quotes with double quotes. JSON only allows double quotes for strings and keys.
  • 2Remove trailing commas after the last property in objects and arrays.
  • 3Wrap all property names in double quotes. Unquoted keys are valid in JavaScript but not in JSON.
  • 4Remove comments. JSON does not support // or /* */ comments.

Frequently Asked Questions

What does the position or column number in the error mean?
It points to the character where the parser first found something invalid. The real mistake is often just before that spot: a missing comma, an unclosed string, or a wrong quote. Read a few characters back from the reported position.
Why does my JSON work in JavaScript but fail to parse?
JavaScript object literals are more permissive than JSON. They allow single quotes, unquoted keys, trailing commas, and comments. JSON, defined by RFC 8259, allows none of these. Valid JavaScript is not always valid JSON.
How do I find the unexpected token quickly?
Run the document through a JSON validator that reports line and column, then inspect that position and the characters right before it. Most issues are a wrong quote type, an unquoted key, or a stray comma.

Check Your JSON Now

Our JSON validator detects this error automatically and shows the exact line and column.

Open JSON Validator
Recommended

Cloudways · Managed Cloud Hosting

Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).

Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303

Start free trial

Related JSON Errors

View all JSON errors