JSON Cheat Sheet

Everything on one page: syntax rules, the six types, escaping, and the errors that catch everyone. Print it (Cmd/Ctrl+P) - it is styled for paper too.

The five rules of JSON

  1. A document is one value: an object, array, string, number, boolean, or null.
  2. Double quotes only - for every key and every string. No single quotes, no unquoted keys.
  3. No trailing commas after the last item of an object or array.
  4. No comments - neither // nor /* */.
  5. Whitespace between tokens is ignored; key order carries no meaning; array order does.

The six data types

TypeExampleNotes
string"hello é \n"Double quotes; unicode escapes allowed
number42, -3.14, 1.2e10No NaN, Infinity, leading zeros, or hex
booleantrue, falseLowercase only
nullnullLowercase only; not None/nil/undefined
object{"key": "value"}Unordered; keys should be unique
array[1, "two", null]Ordered; mixed types allowed

Not JSON types: dates (use ISO 8601 strings), undefined, functions, comments, NaN, Infinity.

String escaping

WriteMeaningRequired?
\"double quoteYes
\\backslashYes
\nnewlineYes (raw newline in a string is invalid)
\ttabYes
\rcarriage returnYes
\b, \fbackspace, form feedYes
\uXXXXunicode code point (\u00e9 = e-acute)Optional for non-ASCII
\/forward slashNever required (allowed)

Need it done for you? Use the JSON Escape tool.

Valid vs invalid at a glance

InvalidValidRule
{'a': 1}{"a": 1}Double quotes for keys and strings
{a: 1}{"a": 1}Keys must be quoted
{"a": 1,}{"a": 1}No trailing commas
{"a": 1 // port}{"a": 1}No comments
{"n": NaN}{"n": null}No NaN/Infinity
{"d": 2026-07-30}{"d": "2026-07-30"}Dates are strings
{"z": 007}{"z": 7}No leading zeros
{"s": "a b"}{"s": "a\n b"}Escape raw newlines

Common errors, decoded

Error messageAlmost always means
Unexpected token < in JSON at position 0You received HTML, not JSON (error page, wrong URL)
Unexpected end of JSON inputEmpty string or truncated document
"[object Object]" is not valid JSONYou parsed an object that was already parsed
Expecting value: line 1 column 1 (char 0)Python: empty/non-JSON input or a BOM
Expecting property name enclosed in double quotesSingle-quoted or unquoted keys, or a trailing comma
Converting circular structure to JSONThe object references itself - JSON cannot represent cycles

All 26 error guides with per-language fixes: JSON error hub.

Parse & serialize one-liners

LanguageParseSerialize (pretty)
JavaScriptJSON.parse(text)JSON.stringify(obj, null, 2)
Pythonjson.loads(text)json.dumps(obj, indent=2)
Gojson.Unmarshal(b, &v)json.MarshalIndent(v, "", " ")
Java (Jackson)mapper.readValue(s, T.class)writerWithDefaultPrettyPrinter()
C#JsonSerializer.Deserialize<T>(s)JsonSerializer.Serialize(v, opts)
PHPjson_decode($s, true)json_encode($v, JSON_PRETTY_PRINT)
RubyJSON.parse(s)JSON.pretty_generate(v)
Rustserde_json::from_str(&s)?serde_json::to_string_pretty(&v)?

Test anything from this page in the JSON Formatter - or try to beat the spot-the-error quiz.

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →