Guide
Common reasons JSON fails to parse
By Logappradeep · ServiceNow developer
A JSON validator answers one question: would a standards-compliant parser accept this text? JSON's grammar, defined in RFC 8259 and ECMA-404, is deliberately small and strict. That strictness is what makes JSON portable across languages, but it also means a single stray character makes the whole document unreadable to the program that receives it.
The mistakes that break JSON most often
- Trailing commas:
{"a": 1,}or[1, 2,]. JavaScript tolerates them; JSON does not. - Single quotes:
{'name': 'Ada'}. Strings and keys must use double quotes. - Unquoted keys:
{name: "Ada"}is a JavaScript object literal, not JSON. - Comments:
//and/* */are not part of the grammar. - Invalid numbers: leading zeros (
007), a leading plus sign,NaN,Infinity, and hexadecimal literals are all rejected. - Non-JSON values:
undefined, functions, and dates written asnew Date()have no JSON form. - Raw control characters in strings: a literal tab or line break inside quotes must be written as
\tor\n. - Unbalanced brackets after copying only part of a larger document.
Reading the error message
When validation fails, a status bar shows the parser's message, for example "Unexpected token" or "Expected property name", together with the line and column where parsing stopped. The reported spot is where the parser gave up, which can be just after the real mistake. A missing comma, for instance, is typically reported at the start of the next value. The exact wording differs between browsers because each JavaScript engine writes its own messages.
Syntax validation versus schema validation
This tool checks syntax: whether the text is well-formed JSON. It does not check meaning, such as whether age is a number, whether email is present, or whether an array has at least one item. That is the job of JSON Schema, a separate vocabulary for describing the expected shape of a document, which is enforced by schema validator libraries in your application or test suite. A document can be perfectly valid JSON and still be the wrong data.
Related formats
Many tools accept relaxed dialects. JSONC (used by VS Code and tsconfig files) allows comments, and JSON5 adds unquoted keys, single quotes, and trailing commas. Those files will be flagged as invalid here, which is correct if the consumer expects strict JSON. Also watch for an invisible byte order mark at the start of files saved by some Windows editors; strict parsers may reject it.
Validation happens in your browser, so you can safely check payloads that contain internal data.