{}JSON-Validator.net
Guide · 7 min read

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.

Find your error instantly
Paste your JSON into the validator to get the exact line and character of the error.
Open Validator

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.

Invalid
{'name': 'Alice', 'active': true}
Valid
{"name": "Alice", "active": true}
Fix:Find and replace all single quotes with double quotes. Be careful not to replace single quotes inside string values — only the delimiters.

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.

Invalid
{
  "name": "Alice",
  "age": 30,
}
Valid
{
  "name": "Alice",
  "age": 30
}
Fix:Remove the comma from the last item in every object and array. Paste your JSON into the validator — it will point to the exact line.

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.

Invalid
{name: "Alice", age: 30}
Valid
{"name": "Alice", "age": 30}
Fix:Wrap every key in double quotes. Keys that are numbers must also be quoted: {"1": "one"}.

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.

Invalid
{
  // user data
  "name": "Alice" /* admin */
}
Valid
{
  "name": "Alice"
}
Fix:Remove all comments before using or parsing the JSON. If you need comments in config files, consider JSONC (used by VS Code) or JSON5 — but note that standard parsers won't accept them.

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.

Invalid
{
  "name": "Alice"
  "age": 30
}
Valid
{
  "name": "Alice",
  "age": 30
}
Fix:Add a comma after every property except the last one. A JSON beautifier makes this easy to spot visually.

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.

Invalid
{
  "users": [
    {"name": "Alice"}
  
}
Valid
{
  "users": [
    {"name": "Alice"}
  ]
}
Fix:Use the validator — it will tell you which line the mismatch occurs on. Beautifying the JSON first makes the nesting structure visually obvious.

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.

Invalid
{"value": undefined, "score": NaN}
Valid
{"value": null, "score": null}
Fix:Replace undefined and NaN with null, or omit the key entirely if the value is truly absent.

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.

Invalid
{"age": "30", "score": "9.5"}
Valid
{"age": 30, "score": 9.5}
Fix:Remove the quotes around numeric values that should be numbers. Keep quotes only for values that are intentionally strings.

Still getting an error?

Paste your JSON into the validator — it will show the exact line and character of every problem.

Validate & Fix JSON

Related Guides