{ }
JSON
JSON Cheat Sheet
JSON syntax, data types, validation rules, and common patterns. Includes examples for objects, arrays, and nesting.
📄 Free PDF Download
Print-friendly · 1-2 pages · No sign-up required
Data Types
| Type | Example | Notes |
|---|---|---|
String |
"hello" |
Must use double quotes |
Number |
42, 3.14, -1 |
Integer or float, no quotes |
Boolean |
true, false |
Lowercase only |
Null |
null |
Lowercase only |
Object |
{"key": "value"} |
Key-value pairs |
Array |
[1, 2, 3] |
Ordered list |
Syntax Rules
- › Keys MUST be double-quoted strings
- › No trailing commas after last item
- › No comments allowed
- › Strings must use double quotes (not single)
- › Top-level value can be any type
- › Numbers: no leading zeros, no NaN/Infinity
Object Example
{
"name": "Alice",
"age": 30,
"active": true,
"score": null,
"tags": ["dev", "api"],
"address": {
"city": "Kyiv",
"zip": "01001"
}
}
Common Errors
| Error | Wrong | Fixed |
|---|---|---|
Trailing comma |
{"a": 1,} |
{"a": 1} |
Single quotes |
{'key': 'val'} |
{"key": "val"} |
Unquoted key |
{key: "val"} |
{"key": "val"} |
Comment |
// comment
{"a":1} |
{"a": 1} |
Python Quick Reference
import json
# Parse JSON string
data = json.loads(json_string)
# Convert to JSON string
json_str = json.dumps(data, indent=2)
# Read from file
with open('data.json') as f:
data = json.load(f)
# Write to file
with open('out.json', 'w') as f:
json.dump(data, f, indent=2)
Free Online Tools for JSON
Keep This Reference Handy
Download the PDF and keep it on your desk or share with your team.
Download JSON Cheat Sheet PDF