JSON Syntax Validator & Auto-Repair
Paste malformed JSON and get the line, the column and what the grammar expected there. The repair pass handles the three shapes humans actually produce and will not touch a single character inside your string values.
- Location comes from a grammar walk. Several of the engine's own messages carry no offset at all — a trailing comma inside an array is one of them — so a validator that reads the error text can only locate some malformations. This one reports a line and column for every rejection.
- Repair does three things: removes trailing commas, quotes unquoted keys, converts single-quoted strings. It does not add comments,
NaN,Infinity, hex or leading zeros, because those are not JSON. A file full of them is a JavaScript object literal, andeval-ing it to "fix" that is an injection hole. - Duplicate keys are legal JSON and silently collapse.
{"a":1,"a":2}validates and reports one key; the count below tells you when the input had more names than the value has.
More from JSONBeautify
Guides
Frequently Asked Questions
Why does the validator call my JSON valid when a key appears twice?
Because duplicate keys are legal JSON syntax: the standard only says names should be unique. JSON.parse keeps the last value, so the validator reports the document as valid and then warns how many duplicate names were collapsed, since the earlier values are silently lost.
Does the validator change my numbers?
It never rewrites your text, but it warns when a number cannot survive parsing. Integers beyond 9007199254740991 come back changed from JSON.parse, so 9007199254740993 is read as 9007199254740992. If those values are IDs, send them as strings.
What exactly does Repair change?
Three things only: it removes trailing commas, quotes unquoted keys and converts single-quoted strings to double quotes, then validates the result again. It leaves comments, NaN, Infinity and hex numbers alone, because those are not JSON and guessing at them could change your data.