Common JSON Errors and How to Fix Them
Troubleshoot and fix the most frequent JSON parsing errors with clear examples and solutions.
Quick fix: Paste your JSON into our JSON Formatter - it automatically fixes many common errors like trailing commas and single quotes.
1. Trailing Comma
A comma after the last item in an object or array is not allowed in JSON.
{
"name": "John",
"age": 30, // Error: trailing comma
}{
"name": "John",
"age": 30
}Fix: Remove the comma after the last property or array element.
2. Single Quotes Instead of Double Quotes
JSON requires double quotes for strings. Single quotes are not valid.
{
'name': 'John' // Error: single quotes
}{
"name": "John"
}Fix: Always use double quotes (") for strings and keys in JSON.
3. Unquoted Keys
All keys in JSON must be strings enclosed in double quotes.
{
name: "John" // Error: unquoted key
}{
"name": "John"
}Fix: Wrap all object keys in double quotes.
4. Missing Comma Between Items
Each item in an object or array must be separated by a comma.
{
"name": "John"
"age": 30 // Error: missing comma
}{
"name": "John",
"age": 30
}Fix: Add commas between all items except after the last one.
5. Comments in JSON
Standard JSON does not support comments. They will cause parse errors.
{
"name": "John",
// This is a comment - NOT ALLOWED
"age": 30
}{
"name": "John",
"age": 30
}Fix: Remove all comments from JSON. Use a separate documentation file if needed.
6. Undefined or NaN Values
JSON only supports null, not undefined or NaN.
{
"value": undefined, // Error
"number": NaN // Error
}{
"value": null,
"number": 0
}Fix: Use null instead of undefined. Replace NaN with a valid number or null.
7. Unclosed Brackets or Braces
Every opening bracket must have a matching closing bracket.
{
"items": [1, 2, 3
}{
"items": [1, 2, 3]
}Fix: Check that all { } and [ ] brackets are properly matched and closed.
8. Invalid Escape Sequences
Backslashes must be properly escaped in strings.
{
"path": "C:\Users\name" // May cause issues
}{
"path": "C:\\Users\\name"
}Fix: Use double backslashes (\\) or forward slashes (/) in paths.
Quick Reference
- • Always use double quotes for strings and keys
- • No trailing commas after the last item
- • No comments in JSON
- • Match all brackets and braces
- • Use null instead of undefined
- • Escape special characters properly
Validate Your JSON Now
Our JSON formatter automatically detects and fixes common errors.
Open JSON Formatter