JSON Cheatsheet
JSON syntax on one page. Reference when writing config files and API data.
Back to Config FormatsData Types 6
"string"String (must use double quotes)
123 / -456 / 3.14Number (integer or float)
true / falseBoolean
nullNull value
{"key": "value"}Object (key-value pairs)
[1, 2, 3]Array (ordered list)
Object 5
{"name": "tom"}Simple object
{"name": "tom", "age": 20}Multi-field object
{"user": {"name": "tom"}}Nested object
{"users": [{"name": "tom"}]}Object containing array
{"key with space": "value"}Key can contain spaces (must be quoted)
Array 5
[1, 2, 3]Number array
["a", "b", "c"]String array
[{"id": 1}, {"id": 2}]Object array
[[1, 2], [3, 4]]2D array
[1, "text", true, null]Mixed type array
Nested 3
{"user": {"name": "tom", "age": 20}}Object nested in object
{"users": [{"name": "tom"}, {"name": "jerry"}]}Object nested in array
[{"id": 1, "tags": ["a", "b"]}]Array of objects with arrays
Common Patterns 4
{"code": 200, "message": "success"}API response format
{"error": {"code": 404, "message": "Not found"}}Error response
{"data": {"items": [], "total": 100}}Paginated data
{"id": 1, "created_at": "2026-07-19T10:30:00Z"}With timestamp
Validation 5
JSON.parse(str)JavaScript parse JSON string
JSON.stringify(obj)JavaScript object to JSON string
JSON.stringify(obj, null, 2)Pretty-print (2-space indent)
jsonlint file.jsonCLI JSON syntax validation
jq . file.jsonCLI JSON pretty-print and query
💡 Tips
- JSON keys must use double quotes — single quotes or unquoted keys are invalid.
- JSON does not support comments. Use JSONC (JSON with Comments) if comments are needed.
- Use ISO 8601 format for date/time (e.g., "2026-07-19T10:30:00Z").