Guide

How to Fix Common JSON Errors

Recognise the common JSON syntax errors, understand what the scanner reports, and know which mistakes a bounded repair can fix safely.

Most invalid JSON fails on a small set of mistakes: a trailing comma, a single-quoted or smart-quoted string, an unquoted object key, a comment that JSON does not allow, or a control character inside a string. A scanner names the first problem and its position, which is usually enough to find it.

01What the scanner reports

  • The first problem only, with a 1-based line, column, and character position.
  • The token it expected versus what it found, for example 'expected , or } in object'.
  • A specific message for duplicate object keys and for unescaped control characters.

02Repair fixes a bounded set

A repair is not a general fixer. It applies a documented, string-aware set of transforms — comments, smart quotes, single-quoted strings, unquoted keys, and trailing commas — then re-parses the result. If the document is still invalid, it reports the first unresolved problem instead of guessing.

03Limitations

Frequently asked questions

Why does a formatter reject a document that a repair could fix?
A formatter only re-emits valid JSON. Repair is a separate, previewed step that fixes a bounded set of common syntax mistakes and re-validates the result before offering it.
Does a repair change any value?
No. Each transform changes only the punctuation or quoting that made the document invalid; every scalar literal is preserved.

Sources

  1. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF (accessed 2026-09-01)