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.
Preview before applying
A safe repair shows the exact change first and only rewrites the document when you confirm; a value is never altered silently.
03Limitations
Limitations
Repair covers only its documented transforms. It cannot invent a missing brace, decide which duplicate key you meant, or fix a value that is the wrong type for your application.
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
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF (accessed 2026-09-01)
Test this in your browser
The tool runs entirely in your browser; the input you use never leaves it.
About the author
Gampangin builds and maintains free, browser-based developer tools and the documentation that makes them trustworthy. The organization is accountable for every page published on this site.