JSON looks forgiving. It is a list of labeled values, that is all. But it has a short list of strict rules, and a parser quits at the first broken one. The good news is that the same handful of mistakes causes nearly every error you will see, so you can learn to spot them in seconds.
The six most common JSON mistakes
1. Trailing commas
JSON does not allow a comma after the last item. JavaScript does, so a shortcut or a habit carries it over and the parser rejects the file.
{ "name": "Ada", "role": "admin", }
Fix: delete the comma before the closing brace or bracket.
2. Single quotes instead of double quotes
JSON demands double quotes for keys and string values. Code copied out of JavaScript or a Python dictionary is full of single quotes, and none of them are valid here.
{ 'name': 'Ada' }
3. Unquoted keys
JavaScript lets you write { name: "Ada" }. JSON forces every key to be quoted.
{ name: "Ada" }
4. Comments
There is no comment syntax in JSON. Files like tsconfig.json that allow // comments are a different format called JSONC. A strict JSON parser will always reject them.
5. Missing or mismatched brackets
Every { needs a matching } and every [ a matching ]. Truncated API responses and copy paste slip ups are the usual cause, and the error appears at the very end of the file.
6. Invisible characters
This one is evil. Copy text out of Word, Google Docs or Slack and the quotes turn curly, "smart quotes" that look identical on screen but break the parser. A byte order mark at the start of a file does the same, blowing up at position 0.
Decoding the error messages
| Error message | What it means | The fix |
|---|---|---|
| Unexpected token } | Trailing comma, or a stray closing brace | Delete the comma before it |
| Unexpected token ' | Single quotes used as string delimiters | Replace them with double quotes |
| Unexpected token n | Unquoted object key | Wrap the key in double quotes |
| Unexpected token / | A // or /* */ comment | Delete every comment |
| Unexpected end of JSON input | A closing bracket is missing | Add the missing } or ] |
| Expected , or } after property | Missing comma between values | Add the comma between items |
| Error at position 0 | BOM or hidden character at the start | Re-save without BOM, or retype the first line |
The parser always stops at the first problem it meets, but the real mistake is often just before that spot. If the error lands on line 8, check line 7 for a missing comma, a lone quote, or a bracket that never closed.
The practical fix workflow
- Paste the broken JSON into a formatter that reports line and column.
- Fix the very first error it reports, then run it again.
- Repeat. The first error often hides the next one, and they surface one at a time.
If the file came from a log or a database export that got cut off mid way, no tool can invent the missing values. In that case, fix the producer so it writes complete records, which is a one line change in most log shippers.
Paste it, and the formatter points straight at the first broken line.
Frequently asked questions
Can JSON files have comments?
No. JSON has no comment syntax by design. Files that allow // comments are called JSONC or JSON5, and a strict JSON parser will reject them.
What does unexpected token in JSON at position 0 mean?
It usually means the file starts with a hidden character like a byte order mark, or the content does not start with a valid JSON value such as an object brace or array bracket.
Are trailing commas allowed in JSON?
No. A comma after the last item in an object or array is invalid JSON. JavaScript allows it, JSON does not, which makes it the single most common JSON error.