Common JSON Errors and How to Fix Them
Clear examples of the mistakes that break JSON, and the quick fix for each one.
JSON looks simple, but one small mistake makes the whole file invalid. Most errors come from the same few problems. This guide shows each one with a wrong and a correct example. If you want to find the exact line of an error in your own data, paste it into our JSON Validator.
1. Missing Comma
Every property in an object, and every item in an array, must be separated by a comma. Browsers usually report this error on the line after the missing comma, so check the end of the line above.
Wrong:
{
"name": "Ayesha"
"city": "Lahore"
}Correct:
{
"name": "Ayesha",
"city": "Lahore"
}2. Trailing Comma
JavaScript allows a comma after the last item, but JSON does not. Remove the comma before a closing bracket or brace.
Wrong:
{
"skills": ["JSON", "CSV",],
}Correct:
{
"skills": ["JSON", "CSV"]
}Tip: our JSON Formatter removes trailing commas automatically when you click Fix & Format JSON.
3. Single Quotes Instead of Double Quotes
JSON only accepts double quotes for keys and text values. Single quotes are a common habit from JavaScript or Python.
Wrong:
{
'name': 'Ayesha'
}Correct:
{
"name": "Ayesha"
}4. Keys Without Quotes
In JavaScript objects, keys can be written without quotes. In JSON, every key must be a string in double quotes.
Wrong:
{
name: "Ayesha",
age: 25
}Correct:
{
"name": "Ayesha",
"age": 25
}5. Comments in JSON
Standard JSON does not support comments of any kind. Remove them, or store the note as a normal property if you need to keep it.
Wrong:
{
// user details
"name": "Ayesha"
}Correct:
{
"note": "user details",
"name": "Ayesha"
}6. Missing or Mismatched Brackets
Every opening brace must have a closing brace, and every opening square bracket must have a closing square bracket. This often happens when copying only part of a file.
Wrong:
{
"skills": ["JSON", "CSV"
}Correct:
{
"skills": ["JSON", "CSV"]
}7. Invalid Values
JSON only allows strings, numbers, true, false, null, objects, and arrays. Values like undefined or NaN are not allowed, and true, false, and null must be written in lowercase.
Wrong:
{
"active": True,
"score": NaN,
"phone": undefined
}Correct:
{
"active": true,
"score": null,
"phone": null
}8. Unescaped Quotes and Backslashes
A double quote inside a text value must be written with a backslash before it, and a backslash itself must be written twice. Windows file paths are a very common cause of this error.
Wrong:
{
"quote": "She said "hello"",
"path": "C:\new\data.json"
}Correct:
{
"quote": "She said \"hello\"",
"path": "C:\\new\\data.json"
}9. Numbers With Leading Zeros
Numbers in JSON cannot start with a zero, unless the number is exactly 0 or a decimal like 0.5. Store values such as ZIP codes or phone numbers as text instead.
Wrong:
{
"code": 007
}Correct:
{
"code": "007"
}Common JSON Error Messages and What They Mean
Browsers and programming languages describe the same mistakes with different messages. Here is what the most common ones mean and how to fix them.
Unexpected token < in JSON at position 0
Your code expected JSON but received an HTML page instead. The < is the start of a tag like <!DOCTYPE html>. This usually means the API URL is wrong, the server returned an error page, or you are not logged in. Open the URL in your browser to see what it really returns.
Unexpected end of JSON input
The JSON stopped before it was complete, or it was completely empty. Check for a missing closing brace or bracket, and make sure the response is not an empty string. See missing or mismatched brackets above.
Unexpected token ' in JSON or Expected property name
The parser found a key that is not wrapped in double quotes. This is caused by single quotes or keys without quotes. Firefox shows this as JSON.parse: expected property name or '}'.
Expected ',' or '}' after property value
A comma is missing between two properties, or there is extra text after a value. Look at the end of the line before the position in the message.
Bad control character in string literal
A text value contains a real line break or tab. Inside JSON strings, write a new line as \n and a tab as \t. More on this and on Windows paths: Bad Escaped Character in JSON.
Python: Expecting value: line 1 column 1 (char 0)
Python's json module received an empty string or something that is not JSON, often an HTML error page. Print the raw text before parsing it to see what you actually received.
Python: Expecting property name enclosed in double quotes
A key uses single quotes or has no quotes, or there is a trailing comma before a closing brace. Python's dictionaries allow single quotes, but JSON does not.
Python: Expecting ',' delimiter
A comma is missing between two items or properties. Check the line and column shown in the message, and the end of the line before it.
How to Find JSON Errors Quickly
- Paste your data into the JSON Validator.
- Read the line and column number of the error.
- Check the end of the line above as well, especially for missing commas.
- Fix the problem and validate again until the JSON is valid.
- Use the JSON Formatter to make the result easy to read.
Python Error Messages
Python's json module words the same mistakes differently. Here is what each JSONDecodeError usually means:
- Expecting property name enclosed in double quotes: a key has no quotes or single quotes, like
{name: 1}or{'a': 1}. Older Python versions also show this for a trailing comma. - Illegal trailing comma before end of object: a comma after the last item (Python 3.13 and newer).
- Expecting ',' delimiter: a comma is missing between two items.
- Expecting value: line 1 column 1 (char 0): the text is empty, or it is not JSON at all, for example an HTML error page.
- Extra data: there is more than one JSON value, often a JSON Lines file. Read it line by line instead.
For JavaScript messages like "Unexpected token < in JSON at position 0", see the full guide to Unexpected Token in JSON; empty or cut-off text is covered in Unexpected End of JSON Input. Errors while writing JSON have their own guides: Converting Circular Structure to JSON (JavaScript) and Object Is Not JSON Serializable (Python). To fix most of these mistakes in one click, paste your JSON into JSON Repair.
Frequently Asked Questions
Why does the error point to the wrong line?
The parser only notices a problem when it reads something it does not expect. For a missing comma, that is usually the start of the next line, so the real mistake is often on the line before.
Is JSON the same as a JavaScript object?
No. JSON is stricter. It needs double quotes, does not allow comments or trailing commas, and only supports a few value types.
Can I convert fixed JSON to a spreadsheet?
Yes. Once your JSON is valid, use the JSON to CSV Converter to open it in Excel or Google Sheets.