GuidesCommon JSON Errors (and How to Fix Them)
Common JSON Errors (and How to Fix Them)
Updated 2026-07-26 · 1 min read · 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.
Trailing commas
Illegal: `{ "a": 1, }`. Legal in JS object literals, illegal in JSON. RFC 8259 does not allow a comma after the last element in an object or array — 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 }`.
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.

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.