DevToolsForYou

JSON Syntax Cheatsheet

A quick reference for JSON syntax — value types, object and array rules, string escapes, and the most common validation mistakes.

Updated Apr 11, 2026
Try the JSON Formatter

Sections

  1. Value Types
  2. Object Rules
  3. Array Rules
  4. String Escape Sequences
  5. Common Validation Errors

Value Types

TypeExampleNotes
String"hello world"Must use double quotes. Single quotes are invalid.
Number42 3.14 -7 1.5e10Integer or float. No NaN, Infinity, or hex literals.
Booleantrue falseLowercase only. True / False are invalid.
NullnullLowercase only.
Object{"key": "value"}Keys must be double-quoted strings.
Array[1, "two", false, null]Ordered list of any value types.

Object Rules

RuleValidInvalid
Keys must be strings{"name": "Jane"}{name: 'Jane'}
Keys must use double quotes{"key": 1}{'key': 1}
No trailing comma{"a": 1, "b": 2}{"a": 1, "b": 2,}
No comments{"rate": 0.5}{"rate": 0.5 /* tax */}
Duplicate keys — avoid{"id": 1}{"id": 1, "id": 2} (undefined behavior)

Array Rules

RuleValidInvalid
No trailing comma[1, 2, 3][1, 2, 3,]
Mixed types allowed[1, "two", null, true]— (all fine in JSON)
Nested arrays OK[[1, 2], [3, 4]]— (no restriction)

String Escape Sequences

SequenceCharacter
\"Double quote
\\Backslash
\/Forward slash (optional)
\bBackspace
\fForm feed
\nNewline
\rCarriage return
\tTab
\uXXXXUnicode code point (4 hex digits)

Common Validation Errors

ErrorBad ExampleFix
Trailing comma{"a": 1,}{"a": 1}
Single-quoted key{'a': 1}{"a": 1}
Unquoted key{a: 1}{"a": 1}
Comment{"x": 1 // comment}{"x": 1}
undefined value{"x": undefined}{"x": null}
NaN / Infinity{"x": NaN}{"x": null} or use a number
Unescaped newline{"s": "line1 line2"}{"s": "line1\nline2"}
Related guidesAll guides →