How to Fix Common JSON Syntax Errors
JSON is strict, and a single stray character breaks the whole file. The good news: almost every error falls into a handful of categories. Here's how to recognize and fix each.
1. Trailing commas
JSON does not allow a comma after the last item:
{ "a": 1, "b": 2, } ← invalid (comma after 2)
{ "a": 1, "b": 2 } ← valid
This is the most common error, especially after deleting a line. Remove the final comma in any object or array.
2. Single quotes instead of double
JSON keys and string values must use double quotes. {'a': 1} is invalid; it must be {"a": 1}. Single quotes are valid in JavaScript but not in JSON.
3. Unquoted keys
Every key needs quotes: {name: "Sam"} is invalid; use {"name": "Sam"}. (This trips up people coming from JavaScript object literals.)
4. Missing or mismatched brackets
Every { needs a } and every [ a ]. A missing closing bracket usually shows as an error at the very end of the file. Pretty-printing helps you see the nesting and spot the gap.
5. Wrong value types
- Strings must be quoted:
"status": active→"status": "active". - Use
true/false/nulllowercase and unquoted for those literals. - No comments allowed —
// like thisbreaks JSON. - No trailing decimal or leading zeros:
.5→0.5.
6. Unescaped characters in strings
Inside a string, a literal double quote or backslash must be escaped: "He said \"hi\"". Newlines inside strings must be \n, not actual line breaks.
Find the error fast
Paste your JSON into our JSON formatter — it validates instantly and points to the line and column of the problem, so you don't have to hunt. Everything runs in your browser, so even sensitive data stays private.
FAQ
Can JSON have comments?
No. If you need comments (e.g. config files), use JSON5 or JSONC, but standard JSON parsers will reject them.
Why does my error say "unexpected token"?
The parser hit a character it didn't expect — often a trailing comma, single quote, or missing bracket at that position.