Back to Blog
JSON February 2025

Fix Unexpected Token in JSON

"Unexpected token" is one of the most common JSON errors. It usually means the parser hit a character or symbol where it didn't expect one. This guide explains the usual causes and how to fix them using a JSON validator that shows the exact line and column.

What Does "Unexpected Token" Mean?

JSON has strict syntax: double quotes for strings, no trailing commas, no comments. When the parser encounters something that breaks those rules—for example a comma after the last array element—it throws "Unexpected token". The token might be }, ], or a character like , in the wrong place.

Common Cause 1: Trailing Comma

JSON does not allow a comma after the last item in an array or object. JavaScript allows it; JSON does not. Fix: remove the trailing comma before ] or }. Use our JSON validator to see the line number, or read our dedicated guide on removing trailing commas in JSON.

Common Cause 2: Comments

JSON does not support // or /* */. If you copied JavaScript or a config that allows comments, strip them before parsing. Many "JSON with comments" formats (e.g. JSONC) are not valid JSON.

Common Cause 3: Single Quotes or Unquoted Keys

Keys and string values must use double quotes. Single quotes or unquoted keys cause "Unexpected token". Replace single quotes with double quotes and ensure every key is quoted.

How to Find the Error Quickly

Paste your JSON into our JSON validator or JSON formatter. We report the first error and the line (and column when available). Fix that spot and validate again until the JSON is valid.

Summary

Fix "Unexpected token" by removing trailing commas, stripping comments, and using double quotes for all keys and strings. Use a validator to get the exact location. For more on parse errors, see JSON parse error at position explained and our developer tools.