GuidesCommon JSON Errors (and How to Fix Them)

Common JSON Errors (and How to Fix Them)

Updated 2026-07-23 · SparkJSON

Most “invalid JSON” failures come from a short list of mistakes copied from JavaScript object syntax: trailing commas, single quotes, unquoted keys, comments, and duplicate keys. Here’s how to spot and fix each one quickly.

Open free JSON formatter →

Trailing commas

Illegal: `{ "a": 1, }`. Legal in JS object literals, illegal in JSON. Remove the final comma before `}` or `]`.

Single quotes and unquoted keys

JSON requires double-quoted strings and double-quoted object keys. `{ 'a': 1 }` and `{ a: 1 }` both fail. Convert to `{ "a": 1 }`.

Comments and non-JSON literals

JSON has no comments. `undefined`, `NaN`, and `Infinity` are not valid JSON values. Use `null` or omit the field, depending on your API contract.

Duplicate keys

Objects with the same key twice are ambiguous. JavaScript’s JSON.parse keeps the last value. SparkJSON warns so you don’t lose data silently.

FAQ

Why does my browser accept JSON that SparkJSON rejects?
You may be evaluating a JS object literal, not parsing JSON. JSON.parse and strict validators are stricter than the JS object grammar.