How to Fix Invalid JSON
Getting a JSON parse error? This guide covers every common reason JSON fails validation, with clear before/after examples and exact steps to fix each one. Paste your JSON into the validator below to find the exact error location, then use this guide to fix it.
1. Single quotes instead of double quotes
The most common JSON error. Developers used to JavaScript or Python naturally reach for single quotes, but JSON strictly requires double quotes for all strings and keys.
{'name': 'Alice', 'active': true}{"name": "Alice", "active": true}2. Trailing comma after last item
JavaScript allows trailing commas in arrays and objects. JSON does not. A comma after the last element is a syntax error in every JSON parser.
{
"name": "Alice",
"age": 30,
}{
"name": "Alice",
"age": 30
}3. Unquoted object keys
In JavaScript, object keys don't need to be quoted: {name: 'Alice'} is valid JS. In JSON, every key must be a string wrapped in double quotes.
{name: "Alice", age: 30}{"name": "Alice", "age": 30}4. Comments in JSON
Standard JSON (RFC 8259) does not support comments of any kind. Neither // single-line nor /* */ multi-line comments are valid JSON.
{
// user data
"name": "Alice" /* admin */
}{
"name": "Alice"
}5. Missing comma between properties
Each key-value pair in an object and each element in an array must be separated by a comma. Forgetting a comma is easy when adding new properties manually.
{
"name": "Alice"
"age": 30
}{
"name": "Alice",
"age": 30
}6. Mismatched braces or brackets
Every opening { must have a matching closing }, and every [ must have a matching ]. Missing or extra braces cause parser errors that can be hard to track in large JSON.
{
"users": [
{"name": "Alice"}
}{
"users": [
{"name": "Alice"}
]
}7. Undefined or NaN values
undefined and NaN are JavaScript values but are not valid JSON. Only string, number, boolean, null, object, and array are valid JSON value types.
{"value": undefined, "score": NaN}{"value": null, "score": null}8. Numbers as strings vs actual numbers
Not a syntax error, but a common logical mistake. {"age": "30"} is valid JSON but the value is a string, not a number. This causes type errors when parsed.
{"age": "30", "score": "9.5"}{"age": 30, "score": 9.5}Still getting an error?
Paste your JSON into the validator — it will show the exact line and character of every problem.
Validate & Fix JSON