JSON looks simple, but it’s strict about syntax in ways that trip people up constantly — especially when you’re hand-editing a config file or copying a snippet from somewhere that wasn’t quite valid JSON to begin with. Here are the errors that come up most often, why they happen, and how to fix each one. If you’d rather not debug it by eye, paste the broken JSON into the JSON Formatter and it’ll point you to the problem directly.
1. Trailing commas
A comma left after the last item in an object or array is one of the most common JSON errors, mostly because it’s perfectly legal in JavaScript object literals — just not in JSON itself.
{
"name": "Alex",
"role": "admin",
}
Fix: remove the comma after the last value. "role": "admin" should be the final line with no trailing comma before the closing brace.
2. Single quotes instead of double quotes
JSON requires double quotes for both keys and string values. Single quotes are common in JavaScript and Python, so they slip in constantly when converting code between the two.
{
'name': 'Alex'
}
Fix: replace every single quote with a double quote: {"name": "Alex"}.
3. Unquoted object keys
In JavaScript you can write {name: "Alex"} and it works fine. In JSON, every key must be a quoted string, no exceptions.
{
name: "Alex"
}
Fix: wrap the key in double quotes: {"name": "Alex"}.
4. Mismatched or missing brackets and braces
Every { needs a matching }, and every [ needs a matching ]. This is the hardest error to spot by eye in a long document, because the mismatch can be dozens of lines away from where the error actually shows up.
{
"users": [
{ "name": "Alex" },
{ "name": "Sam" }
}
Fix: count your opening and closing brackets. In this example the array that starts with "users": [ is never closed with a matching ] before the final }. A formatter that indents nested structure automatically makes this kind of gap far easier to spot than reading a single dense line.
5. Using undefined, NaN, or functions as values
JSON only supports strings, numbers, booleans, objects, arrays, and null. Values like undefined, NaN, or an actual function — all valid in JavaScript — are not valid JSON and will fail to parse.
{
"score": NaN,
"callback": undefined
}
Fix: use null for a missing value, and remove or replace anything that isn’t a plain data type.
6. Duplicate keys
Technically most JSON parsers won’t throw an error for a duplicate key — they’ll just silently use the last one and discard the first, which can hide a real bug for a long time.
{
"status": "active",
"status": "pending"
}
Fix: there’s no syntax fix here, just a logic one — decide which value you actually meant and delete the other key entirely.
7. Comments
JSON has no comment syntax at all — not //, not /* */. This catches people who are used to JSON5 or JSONC (used in things like VS Code’s settings file), which do allow comments but aren’t the same format as plain JSON.
{
// this is the user's name
"name": "Alex"
}
Fix: delete the comment entirely, or move that context into a key’s own value if you need it documented somewhere.
Catching these automatically
All seven of these are easy to miss by eye in anything longer than a few lines. Paste your JSON into the JSON Formatter and it will validate the structure, point out what’s wrong, and auto-indent the result so nested brackets are easy to trace by sight — free, with no signup required.
Related Guides
More on working with JSON and structured data: