JSON is the most common format for web APIs, configuration files, and data storage. Because it is simple to read, many developers and configuration managers edit JSON files by hand. However, JSON has extremely strict syntax rules. Unlike JavaScript or Python, JSON does not tolerate small human errors.
A single misplaced character can break an entire build, crash an API integration, or halt a application. Here are the five most common JSON syntax errors and how to fix them.
1. Trailing Commas
In JavaScript, Python, and many other programming languages, trailing commas at the end of an array or object are perfectly valid. They make git diffs cleaner when adding new items.
In JSON, trailing commas are completely forbidden.
Invalid JSON
{
"name": "Alice",
"roles": ["admin", "editor",]
}
The Fix
Remove the comma after the last item.
{
"name": "Alice",
"roles": ["admin", "editor"]
}
If you have a large file with dozens of nested trailing commas, manually finding them can be slow. You can use our client-side JSON Parser to automatically strip out all trailing commas instantly.
2. Single Quotes Instead of Double Quotes
This is a frequent issue when copying data from Python dictionaries, JavaScript console outputs, or SQL databases. Python uses single quotes by default to represent strings, but JSON strictly requires double quotes.
Invalid JSON
{
'id': 101,
'status': 'active'
}
The Fix
Change all single quotes wrapping keys and values to double quotes.
{
"id": 101,
"status": "active"
}
Note: If your strings contain nested quotes, make sure to escape them using \" rather than switching to single quotes.
3. Unquoted Object Keys
In JavaScript, you can omit quotes around object keys if they are valid identifiers.
JSON requires all keys to be strings, which means they must be wrapped in double quotes.
Invalid JSON
{
user_id: 202,
username: "charlie"
}
The Fix
Wrap all keys in double quotes.
{
"user_id": 202,
"username": "charlie"
}
4. Comments in the Code
Standard JSON does not support comments. Inserting JavaScript-style single-line (//), multi-line (/* */), or Python-style (#) comments will cause the parser to fail.
Invalid JSON
{
// User ID from the database
"id": 303,
"status": "inactive" # pending verification
}
The Fix
Remove all comments before parsing or saving the JSON data.
{
"id": 303,
"status": "inactive"
}
If you must include documentation, consider using a dedicated key like "_comment": "User ID from database". Alternatively, use our JSON Parser which automatically cleans comments from your data before formatting it.
5. Python-Style Booleans and Nulls
If you work with Python, you are used to writing True, False, and None. If you dump or paste a Python dictionary directly into a JSON file, these language-specific literals will break the parser.
JSON is case-sensitive and strictly requires lowercase values.
Invalid JSON
{
"active": True,
"verified": False,
"profile": None
}
The Fix
Convert Python literals to their JSON equivalents:
TruebecomestrueFalsebecomesfalseNonebecomesnull
{
"active": true,
"verified": false,
"profile": null
}
How to Automatically Fix JSON Errors
Manually scanning files for missing quotes, unquoted keys, or trailing commas is slow and tedious.
Our browser-based JSON Parser has a built-in auto-repair pipeline. When you paste broken JSON or upload a malformed .json file, the parser runs a client-side state machine that automatically:
- Translates Python literals (
True,False,None) - Convers single quotes to double quotes while preserving nested characters
- Strips trailing commas and comments
- Quotes unquoted keys
All processing happens locally in your browser. No data ever leaves your computer. For general formatting and pretty-printing, you can also use our JSON Formatter.