JRJI
All articles
JSON · 6 min

The 5 JSON mistakes the Fixer catches automatically

Trailing commas, unquoted keys, single quotes, comments — a tour of the formatting bugs that break real-world JSON.

JSON’s grammar fits on a napkin, yet broken JSON is everywhere. The reason is simple: most broken JSON isn’t written by hand from scratch — it is copied out of JavaScript source, exported by a sloppy script, or trimmed from a log line. Along the way it picks up habits that JavaScript tolerates and JSON does not.

Here are the five failures the JSON Fixer repairs automatically, and why they happen.

1. Trailing commas

{
  "name": "jrji",
  "tools": ["fixer", "diff",],
}

Modern JavaScript, Python, and most linters actively encourage trailing commas — they make diffs cleaner. JSON forbids them entirely. This is the single most common breakage we see, and it almost always comes from pasting a JS object literal into a .json file.

The fix: remove any comma that directly precedes a closing } or ].

2. Unquoted object keys

{ name: "jrji", version: 2 }

Perfectly valid JavaScript, invalid JSON. Every key in JSON must be a double-quoted string. Objects copied from JS code, MongoDB shell output, or dev-console dumps all arrive in this form.

The fix: wrap bare identifiers used in key position in double quotes.

3. Single quotes

{ 'status': 'active' }

Python’s repr(), older YAML emitters, and hand-written JS all default to single quotes. JSON only accepts ". This one is deceptively tricky to repair, because a naive find-and-replace corrupts apostrophes inside strings ('it's broken'). A repair pass has to track whether it is inside a string before swapping quotes.

The fix: convert quote delimiters to double quotes while preserving embedded apostrophes.

4. Comments

{
  // enable in prod
  "cache": true
}

Douglas Crockford removed comments from JSON on purpose, but the need never went away — which is why JSONC, JSON5, and countless config loaders quietly accept them. The moment such a file reaches a strict parser (JSON.parse, most APIs), it explodes.

The fix: strip // line comments and /* */ block comments before parsing.

5. Wrong-but-close literals

{ "deleted": False, "parent": None }

Python’s True/False/None, printed straight to a log, are one capital letter away from valid JSON. The same category includes undefined and NaN leaking out of JavaScript. Strict parsers reject them all.

The fix: normalize to true, false, and null.

Why “best effort” is the honest label

The Fixer is a heuristic, not a parser with a formal error-recovery grammar. Deeply structural damage — a missing closing brace three levels up, two objects fused together, truncated output from a crashed process — often has multiple valid repairs, and a tool that silently picks one can invent data you never had. When repair is ambiguous, failing loudly beats guessing quietly.

For the everyday cases above, though — the ones that account for the vast majority of real-world breakage — one click gets you valid, pretty-printed JSON, without your payload ever leaving the browser.

Got a stubborn document? Paste it into the JSON Fixer and see what it catches.