What counts as valid JSON
JSON is a strict subset of JavaScript syntax. It allows objects, arrays, strings in double quotes, numbers, true, false and null. It does not allow comments, trailing commas, single quotes, unquoted keys, NaN, Infinity or leading + signs.
| Valid | Invalid | Why |
|---|---|---|
{"a": 1} | {a: 1} | Keys must be double-quoted |
[1, 2] | [1, 2,] | No trailing commas |
"text" | 'text' | Single quotes are not JSON |
null | undefined | undefined is a JavaScript value, not JSON |
1e3 | +1 | No leading plus sign |
Schema validation is a different job
Syntax validity does not mean the document matches your API contract. A { "age": "old" } object is valid JSON but invalid against a schema that requires an integer. Use JSON Schema tooling for that; this page only checks syntax.
If an API rejects your payload, check both layers: syntax first, then schema (required fields, types, formats).
Common causes of “unexpected token”
- A trailing comma after the last property or array element.
- A comment copied from a JavaScript config file.
- A BOM or invisible character at the start of the file.
- Windows-style smart quotes from a word processor.
- A string containing an unescaped newline or quote.