What is JSON?
JSON (JavaScript Object Notation) is a way to write data as plain text, so programs can store it and send it to each other. APIs return it, config files hold it, and automation tools like n8n pass it from step to step. The name comes from JavaScript, but almost every programming language can read and write it. The format is defined in RFC 8259 and in the ECMA-404 standard.
{
"name": "Ada Lovelace",
"born": 1815,
"mathematician": true,
"spouse": null,
"languages": ["English", "French"],
"address": {
"city": "London",
"country": "GB"
}
}The six kinds of value
Every value in JSON is one of these:
- An object: named values inside
{ }, like{"city": "London"}. Each name is a key, and a key is always text in double quotes, followed by a colon. - An array, or list: values in order inside
[ ], like["English", "French"]. - A string, or text, in double quotes:
"Ada Lovelace". - A number, without quotes:
1815,-3.5or6.02e23. - A boolean:
trueorfalse. null, which means empty: the key is there, but it has no value.
Objects and arrays can hold any value, including other objects and arrays, so data can nest as deep as it needs to. Commas go between the items of an object or array. Spaces, tabs and line breaks between values don't change the data, so the same JSON can be written on one line or spread over many.
A JSON text is usually an object or an array, but any single value counts: 42 and "hello" are valid JSON texts too. JSON shared between systems must be encoded as UTF-8.
Rules that trip people up
- Keys and strings need double quotes. Single quotes and keys without quotes aren't allowed.
- No comma after the last item. See trailing commas.
- No comments. See comments in JSON.
true,falseandnullare lowercase. See True, False and None.- Numbers can't have leading zeros (
007), a leading+, or beNaNorInfinity. See numbers and precision.