Skip to main content
CuteJSON
↑↓ Navigate Enter Select Esc Close

JSON cheat sheet: syntax, data types and operations on one page

Published 3 min read By Akash Kinkar Pandey

Everything on this page fits on one screen on purpose: JSON’s syntax is small enough that a full reference does not need to be long. Read it here, or download the same reference as an image to keep offline or print.

JSON cheat sheet covering structure, syntax rules, data types, common operations, examples and best practices

1. Structure

JSON is written as key-value pairs inside an object ({ }) or as an ordered list inside an array ([ ]). Keys are always strings. Values can be a string, number, boolean, null, array or another object, nested as deep as the data actually needs.

{
  "name": "Ada",
  "age": 36,
  "active": true,
  "skills": ["json", "css"],
  "address": { "city": "London" },
  "nickname": null
}

2. Syntax rules

  • Keys and string values use double quotes. Single quotes are not valid JSON.
  • A colon separates each key from its value.
  • A comma separates pairs and array items, with none after the last one.
  • Arrays are ordered lists, values separated by commas.
  • No comments. Standard JSON has no comment syntax at all, not // and not #.

3. Data types

Type Example Notes
String "hello" Double quotes only
Number 42, -3.14 No hex, no NaN, no leading zero
Boolean true, false Lowercase, unquoted
Null null Lowercase, unquoted
Array ["a", 1, true] Ordered, mixed types allowed
Object {"key": "value"} Keys are always strings

JSON Data Types Explained goes through each of these with the edge cases that catch parsers out.

4. Common operations (JavaScript)

JSON.parse(text)              // string -> value, throws on invalid JSON
JSON.stringify(value)         // value -> string
JSON.stringify(value, null, 2) // pretty printed, 2 space indent
value.key                     // read a key once parsed
value.nested.key              // read a nested key

5. Examples

Array of objects

[
  { "id": 1, "name": "Ada" },
  { "id": 2, "name": "Linus" }
]

Nested object

{ "user": { "id": 1, "verified": true } }

Mixed types

{ "tags": ["a", "b"], "score": null, "live": false }

6. Best practices

  • Use meaningful, consistent key names.
  • Keep structures as flat as the data reasonably allows.
  • Validate JSON before parsing input you did not generate yourself.
  • Use arrays for lists, not objects with numeric-looking keys.
  • Quote large integers as strings if exact precision matters; a 64-bit ID can round in a plain JSON.parse (see JSON Data Types).
  • Handle parse errors explicitly. Never assume input is valid JSON just because it usually is.

Where to go from here

Back to all posts