JSON
JSON is how programs hand structured data to each other. It is small, human-readable, and supported everywhere.
JSON (JavaScript Object Notation) is a text format for structured data. It grew out of JavaScript but is now language-neutral — every major language can read and write it, which is why APIs speak it.
What it looks like
{
"id": 42,
"name": "Ada",
"active": true,
"roles": ["admin", "editor"],
"profile": {
"city": "London",
"age": null
}
}
The whole type system
JSON has just six value types, and that is the point — it is deliberately tiny:
- string — always in double quotes:
"hello" - number —
42,-3.14(no distinction between int and float) - boolean —
trueorfalse - null
- array — ordered list in
[ ] - object — key/value pairs in
{ }; keys are always strings
Parsing and producing it
// JavaScript
const obj = JSON.parse(text); // text -> value
const text = JSON.stringify(obj); // value -> text
JSON.stringify(obj, null, 2); // pretty-printed
# Python
import json
obj = json.loads(text)
text = json.dumps(obj, indent=2)
Rules that trip people up
- Keys and strings must use double quotes, never single.
- No trailing commas.
- No comments — JSON has none.
- No
undefined, no functions, no dates — dates are usually sent as ISO strings like"2026-11-08T12:00:00Z".
Related: YAML and TOML are friendlier for config files (they allow comments), but for machine-to-machine data over the wire, JSON is the default.