10 Common JSON Errors and How to Fix Them
If you work with JSON regularly, you’ve hit an “invalid JSON” error before — and probably more than once wondered exactly what’s wrong when the message itself isn’t much help. The good news is that JSON errors come from a surprisingly small set of root causes. Once you know what to look for, most broken JSON takes seconds to fix rather than minutes of squinting at brackets.
We put together this list based on the errors we see most often when people run their JSON through our validator. If you haven’t already, it’s worth reading our guide to JSON syntax basics first — this article assumes you know the fundamentals and focuses specifically on what goes wrong and how to fix it.
1. Trailing Commas
The error: By far the most common JSON mistake. A comma left after the last item in an object or array.
{
"name": "Kings Tools",
"version": 2,
}
Why it happens: JavaScript object literals and several other languages tolerate trailing commas, so developers coming from those backgrounds instinctively leave one behind — especially after deleting the last property in a hand-edited file.
The fix: Remove the comma after the final value in any object or array.
{
"name": "Kings Tools",
"version": 2
}
2. Unquoted Object Keys
The error:
{name: "Kings Tools"}
Why it happens: This is valid JavaScript object syntax but invalid JSON. JSON requires every key to be a double-quoted string, no exceptions.
The fix:
{"name": "Kings Tools"}
3. Single Quotes Instead of Double Quotes
The error:
{'name': 'Kings Tools'}
Why it happens: Again, this is valid in JavaScript and several other languages, but the JSON specification only permits double quotes for both keys and string values.
The fix: Replace every single quote with a double quote.

{"name": "Kings Tools"}
4. Unescaped Quotes Inside Strings
The error:
{"quote": "She said "hello" to me"}
Why it happens: When a string value itself needs to contain a double quote, it has to be escaped with a backslash. Otherwise, the parser interprets the internal quote as the end of the string, and everything after it becomes a dangling, invalid fragment.
The fix:
{"quote": "She said \"hello\" to me"}
5. Missing or Mismatched Brackets
The error:
{
"user": {
"name": "Alex"
}
Why it happens: In deeply nested JSON, it’s easy to lose track of how many closing braces or brackets you actually need, especially when editing by hand or trimming down a large payload.
The fix: Every { needs a matching }, and every [ needs a matching ]. Count carefully, or better, use a formatter — properly indented JSON makes mismatched brackets visually obvious because the indentation itself breaks.
{
"user": {
"name": "Alex"
}
}
6. Using undefined Instead of null
The error:
{"middleName": undefined}
Why it happens: undefined is a real value in JavaScript, but it has no equivalent in the JSON specification. JSON only recognizes null to represent an empty or missing value.
The fix:
{"middleName": null}
7. Trailing or Leading Zeros in Numbers
The error:
{"code": 007}
Why it happens: JSON numbers can’t have leading zeros (except when the number is exactly 0). This trips people up most often with values like ZIP codes or product codes that naturally start with zero.
The fix: If the value needs to preserve a leading zero (like a ZIP code), it should be stored as a string instead of a number:
{"code": "007"}
8. Comments Left in the File
The error:
{
// user settings
"theme": "dark"
}
Why it happens: Standard JSON has no comment syntax at all — no //, no /* */. This is a frequent source of confusion because some JSON-adjacent formats, like JSONC (used in VS Code’s settings.json) and JSON5, do allow comments, so people assume standard JSON does too.
The fix: Remove the comment entirely, or move that context into a "_comment" key if you need to document something inline:
{
"_comment": "user settings",
"theme": "dark"
}
9. Duplicate Keys in the Same Object
The error:
{
"status": "active",
"status": "inactive"
}
Why it happens: This usually happens when JSON is merged or edited programmatically and a key gets accidentally duplicated. Technically, some parsers will accept this and just use the last value — but it’s not spec-compliant, and behavior can vary between different JSON parsers, which makes it a silent source of bugs rather than a clean error.
The fix: Every key within the same object should appear only once. Decide which value is correct and remove the duplicate.
10. Wrapping the Entire JSON in Extra Quotes
The error:
"{\"name\": \"Kings Tools\"}"
Why it happens: This happens when JSON has been stringified twice — for example, when a JSON payload gets JSON.stringify()‘d a second time by accident, often when passing data between systems that each expect to handle the serialization step themselves.
The fix: Parse it once to unwrap the outer string, and you’ll be left with the actual JSON underneath:
{"name": "Kings Tools"}
Quick Reference Table
If you just need a fast lookup rather than the full explanation above, here’s every error in one table:
| # | Error | Invalid Example | Fix |
|---|---|---|---|
| 1 | Trailing comma | {"a": 1,} | Remove the final comma |
| 2 | Unquoted key | {name: "x"} | {"name": "x"} |
| 3 | Single quotes | {'name': 'x'} | {"name": "x"} |
| 4 | Unescaped quote | "He said "hi"" | "He said \"hi\"" |
| 5 | Mismatched brackets | {"a": {"b": 1} | Add the missing } |
| 6 | undefined value | {"a": undefined} | {"a": null} |
| 7 | Leading zero | {"code": 007} | {"code": "007"} |
| 8 | Comments | // note | Remove or use a _comment key |
| 9 | Duplicate keys | {"a":1,"a":2} | Keep only one "a" key |
| 10 | Double-stringified | "{\"a\":1}" | Parse once to unwrap |
Frequently Asked Questions
Why does my JSON error message not tell me exactly what’s wrong?
Many JSON parsers report only a character position, not a plain-English description — which is technically accurate but not very human-friendly. A good validator converts that raw position into a line and column number so you can jump straight to the problem instead of counting characters.
What’s the fastest way to check JSON for errors before deploying it?
For quick manual checks, an online validator is usually fastest since there’s no setup involved. For automated checks in a pipeline or script, most languages have a built-in JSON parser (like Python’s json module) that will raise an error on invalid input, which you can catch programmatically.
Can invalid JSON still “work” sometimes?
In some cases, yes — certain parsers are lenient and will silently tolerate things like trailing commas or duplicate keys. This is actually more dangerous than a hard failure, because your data can behave unpredictably across different systems: one API might accept JSON that another rejects outright, since they’re not required to enforce the specification identically.
Do all JSON errors stop the whole file from working?
Yes — unlike some more forgiving formats, JSON parsing is all-or-nothing. A single syntax error anywhere in the document, even in a small nested value, will cause the entire file to fail parsing rather than just that one section.
How to Catch These Faster
Reading through a large JSON payload line by line looking for one of these ten issues is slow and error-prone. A validator that points to the exact line and column where parsing failed cuts that process down from minutes to seconds — which is exactly what our JSON Formatter and Validator does. Paste your JSON in, and if something’s broken, you’ll see precisely where, instead of scanning the whole document by eye.
Summary
Almost every JSON error traces back to one of these ten patterns: trailing commas, unquoted or single-quoted keys, unescaped characters, mismatched brackets, non-JSON values like undefined, malformed numbers, stray comments, duplicate keys, or double-stringified data. Once you can recognize these on sight, debugging JSON stops being a guessing game and becomes a quick, mechanical check.
