JSON validator
Property name must be a string literal
Processed in your browser · nothing is uploaded
Puts the document through a real parser and names the first thing the grammar refuses, turning the character offset a JavaScript engine reports into a line and a column. The sample above ends with a trailing comma: legal JavaScript, illegal JSON, and the single commonest reason a request body comes back rejected.
How to use the json validator
A validator answers one question, will a parser accept this, and the useful part is where it stops. Engines report a character offset: "Unexpected token } in JSON at position 2841" is accurate and no help at all in a four-thousand-character body, so the offset is converted here into a line and a column you can go to.
The grammar is smaller than people expect and refuses things that look reasonable. Numbers take no leading plus, no leading zero and no bare decimal point, so 0123, +5, 1. and .5 are all rejected; NaN and Infinity cannot be written at all, which is why a serialiser that produced one has already gone wrong upstream. Strings must be double-quoted, and every character below U+0020 has to be escaped. A real tab or newline sitting inside the quotes is a syntax error, which is what breaks a payload assembled by pasting multi-line text into a field. And a byte order mark is not part of the grammar, so a file Excel or Notepad saved with one fails at the very first character.
One thing worth knowing before you trust a rejection from somewhere else: what counts as a whole document changed. Since RFC 7159 in 2014 any value stands alone, so "ok", 42 and null are each complete JSON. RFC 4627, from 2006, required an object or an array at the top, and an endpoint written against that older rule will refuse a document this page calls valid. Duplicate keys sit in a similar gap: the specification says names SHOULD be unique and leaves the rest undefined, so a document with two of the same key is not invalid and is read differently by different parsers.
What validity does not buy you is the shape. A missing required field, a number sent as a string, an ISO date where an integer was expected: all of them parse. That is schema validation, a separate job done with JSON Schema, and the distinction matters because "the JSON is valid" gets offered as a reason an integration should work when the real problem is a field the receiver needed and did not get.
What people use it for
- Finding out why an endpoint returned 400 on a body that looks fine
- Turning a parser’s character offset into a place in the document
- Checking a config file parses before restarting the service that reads it
- Confirming a hand-edited fixture still loads
- Deciding whether a rejection is a syntax fault or a missing field
Questions
The three usual causes are a trailing comma after the last item, single quotes instead of double, and unquoted keys. All three are valid JavaScript and none is valid JSON.
Because JavaScript engines count characters from the start of the string. That offset is converted here into a line and a column, which is the form you can act on.
Yes, since RFC 7159 in 2014: any value on its own is a complete document. RFC 4627 required an object or an array at the top, so an older endpoint may refuse what this accepts.
JSON numbers allow no leading plus, no leading zero and no bare decimal point, so 0123, +5, 1. and .5 all fail. NaN and Infinity cannot be written at all.
No. Every character below U+0020 must be escaped, so a literal newline or tab between the quotes is a syntax error rather than a formatting choice.
No. Validity is syntax only. A missing required field or a number sent as a string is valid JSON and still wrong for the endpoint.
A way of describing the expected shape: required fields, types, ranges, so a document can be checked against it. Different from syntax validation.
The specification says names SHOULD be unique and leaves the behaviour undefined, so they are not invalid. Most parsers keep the last one, which means passing validation is no assurance the receiver reads the document the way you meant.
No. It is parsed by the JavaScript engine already running this page, which is why an API response with live data in it can be checked here.