JSON Syntax Cheat Sheet
Everything you need to write valid JSON on one page. Use your browser's print command (Ctrl+P) to save it as a PDF.
The six value types
| Type | Rule | Example |
|---|---|---|
object | Key and value pairs in { }. Keys are strings in double quotes. | {"name": "Ada", "age": 36} |
array | An ordered list in [ ], items separated by commas. | [1, 2, 3] |
string | Text in double quotes. Single quotes are not allowed. | "hello" |
number | Integer or decimal, optional minus and exponent. No NaN, Infinity or leading zeros. | -12.5e3 |
boolean | Lowercase true or false, no quotes. | true |
null | Lowercase null, an explicit empty value. | null |
String escapes
A backslash starts an escape. Any other character after a backslash is an error.
| Escape | Meaning | Example |
|---|---|---|
\" | Double quote | "say \"hi\"" |
\\ | Backslash | "C:\\Users" |
\/ | Slash (optional) | "a\/b" |
\n \r \t | Line feed, carriage return, tab | "line1\nline2" |
\b \f | Backspace, form feed | "\b" |
\uXXXX | Any character by its four-digit hex code | "\u00e9" is é |
Not allowed in JSON
| Not allowed | Why | Use instead |
|---|---|---|
Comments (// or /* */) | JSON has no comments. | A "_comment" key, or JSONC/YAML |
Trailing commas | A comma after the last item is an error. | Remove the last comma |
Single-quoted strings | Only double quotes are valid. | "text" |
Unquoted keys | Keys must be strings. | {"key": 1} |
undefined, NaN, Infinity | They are not JSON values. | null, or a string |
Raw line breaks inside strings | Control characters must be escaped. | \n |
Multiple top-level values | A document has exactly one value. | Wrap them in an array |
Good to know
- JSON text is UTF-8 and may start with any value, not only an object.
- Numbers have no type: 1 and 1.0 are the same. Integers above 9,007,199,254,740,991 lose precision in JavaScript, so send them as strings.
- Dates have no type. Use ISO 8601 strings such as 2026-10-30T12:00:00Z.
- Duplicate keys are allowed by the syntax but undefined in meaning. Avoid them.