Skip to content

JSON Syntax Guide

JSON types, syntax errors and safe serialization examples.

By ToolzHive · Updated

JSON is a text format, not executable JavaScript. Validate syntax separately from the requirements of an API or schema.

Download reference CSV

Reference table

JSON Syntax Guide
Type or ruleExampleDetail
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.5e2No NaN or Infinity
Booleantrue / falseLowercase without quotes
NullnullLowercase without quotes
CommentsNot allowedRemove JavaScript comments
Trailing commaNot 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

Sources

Related references

Browse all free resources

Accessibility Menu

Personalize your experience. Open with Ctrl+U (Option+U on Mac). Preferences stay in this browser when storage is available.

Move / Hide Widget

Restore at any time with Ctrl+U (Option+U on Mac).

Accessibility statement and help