7 common JSON errors and how to fix them
Nov 2, 2026 · 5 min read
JSON looks like JavaScript, but its grammar is much stricter. Most "Unexpected token" errors come from a handful of mistakes, and each one is quick to fix once you know where to look.
The fastest way to locate a mistake is to paste the text into the JSON Validator. It reports the line and column of the first problem instead of a bare "Unexpected token".
1. Trailing commas
A comma after the last item of an object or array is valid in JavaScript but not in JSON. Remove it.
{
"name": "demo",
"tags": ["a", "b"],
}2. Single quotes
JSON strings and property names must use double quotes. {'a': 1} fails; {"a": 1} works.
3. Unquoted property names
{a: 1} is a JavaScript object literal, not JSON. Wrap every key in double quotes.
4. Comments
JSON has no comments. // and /* */ make parsing fail. Delete them, or keep notes in a separate field such as "_note".
5. Raw line breaks and tabs inside strings
A literal newline inside a string is not allowed. Write it as \n and a tab as \t. If you are pasting a string that has already been escaped, try the unescape button in the JSON Formatter.
6. Values JSON does not have
undefined,NaNandInfinityare not valid values. Usenullor a string instead.
- Numbers cannot have leading zeros (
007), a leading plus sign or a trailing dot (1.).
- Only
true,falseandnullare valid in lowercase;TrueorNonewill fail.
7. Invisible characters and extra data
A byte order mark at the start of a file, or a second JSON value after the first, also triggers errors. Copy the text again from the source, or check the end of the input for stray characters.
After it parses
Once the text is valid, use the JSON Formatter to make it readable, the JSON Minifier to shrink it for transport, or JSON to TypeScript to generate types from a sample response. Everything runs in your browser, so nothing you paste is uploaded.

