By ToolzHive · Updated
JSON is a text format, not executable JavaScript. Validate syntax separately from the requirements of an API or schema.
Reference table
| Type or rule | Example | Detail |
|---|---|---|
| Object | {"name":"Ada"} | Quoted property names |
| Array | [1,2,3] | Any JSON value can be a member |
| String | "line\nnext" | Double quotes and valid escapes |
| Number | -12.5e2 | No NaN or Infinity |
| Boolean | true / false | Lowercase without quotes |
| Null | null | Lowercase without quotes |
| Comments | Not allowed | Remove JavaScript comments |
| Trailing comma | Not allowed | {"a":1,} is invalid |
| Unique keys | {"id":1} | Duplicate names can be interpreted differently |
Copyable example
{
"name": "Ada",
"roles": ["editor"],
"active": true,
"next": null
} Worked example
{"items":[{"id":1,"active":true}],"next":null} contains an object, array, number, boolean and null. Serialize supported data with JSON.stringify instead of assembling JSON by concatenation.
Precision
Large integers may lose precision in JavaScript. Preserve identifiers as strings when required by an API. Parsing without an error does not prove every value survived unchanged.
Try the related tools
- JSON Formatter & Validator — Beautify, minify and validate JSON with helpful error messages.