You're working on your project, everything seems fine, and then it happens: "Invalid JSON." That's the error message. No line number. No explanation. Just "Invalid JSON."
I've been there. It's frustrating. You stare at your JSON, it looks fine to you, but something's wrong and you can't figure out what. The good news? "Invalid JSON" errors are almost always caused by the same few mistakes, and once you know what to look for, they're easy to fix.
Let me show you what "Invalid JSON" actually means, how to find the exact problem, and how to fix it quickly.
What Does "Invalid JSON" Actually Mean?
When you see "Invalid JSON," it means your JSON doesn't follow the rules. JSON has strict syntax requirements, and if you break even one rule, the entire file becomes invalid.
Think of it like a sentence. If you write "The cat sat on the mat" that's valid. But if you write "The cat sat on the mat" (missing period), it's still understandable, just not perfectly formatted. JSON isn't that forgiving. One tiny mistake, and everything breaks.
The problem is, the error message usually doesn't tell you what the mistake is. It just says "Invalid JSON" and leaves you to figure it out. That's where this guide comes in.
Step 1: Find the Exact Error Location
Before you can fix the error, you need to find it. Here's the fastest way:
Use an Online Validator
Paste your JSON into our JSON Formatter and click "Validate." It will tell you exactly what's wrong and where. You'll get messages like:
- "Expected ',' or '}' at line 5, column 12"
- "Unterminated string at line 3"
- "Unexpected token at line 8"
This is gold. Instead of guessing, you get the exact location of the problem.
Alternative: Browser Console
If you're already in your browser, you can use the console:
- Open Developer Tools (F12)
- Go to Console
- Type:
JSON.parse('your json here')
The error message will tell you the position where it failed. It's not as detailed as a validator, but it's quick.
Step 2: The 6 Most Common "Invalid JSON" Errors
After fixing hundreds of these errors, I've noticed the same problems keep coming up. Here they are, in order of how often I see them:
Error #1: Missing Comma
This is the most common one. You forget a comma between properties.
Invalid:
{
"name": "John"
"age": 30
}
Fixed:
{
"name": "John",
"age": 30
}
How to spot it: Look for two properties on consecutive lines without a comma between them.
Error #2: Trailing Comma
JSON doesn't allow commas after the last item in an object or array.
Invalid:
{
"name": "John",
"age": 30,
}
Fixed:
{
"name": "John",
"age": 30
}
How to spot it: Check the last property in each object or array. Remove any trailing comma.
Error #3: Unclosed Quotes
You started a string with a quote but forgot to close it.
Invalid:
{
"name": "John,
"age": 30
}
Fixed:
{
"name": "John",
"age": 30
}
How to spot it: Every string should start and end with quotes. Count your quotes—they should be even.
Error #4: Unclosed Brackets
You opened a curly brace { or square bracket [ but didn't close it.
Invalid:
{
"name": "John",
"age": 30
Fixed:
{
"name": "John",
"age": 30
}
How to spot it: Count your opening and closing brackets. They should match. Every { needs a }, every [ needs a ].
Error #5: Single Quotes Instead of Double
JSON requires double quotes for strings. Single quotes aren't allowed.
Invalid:
{
'name': 'John',
'age': 30
}
Fixed:



