What Is JSON? A Beginner’s Guide
9 min read
JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for storing and exchanging structured data. Despite the "JavaScript" in its name, JSON is language-independent: nearly every programming language can read and write it, which is exactly why it became the de facto standard for sending data between servers, browsers, mobile apps, and APIs.
If you write software for a living, you will touch JSON almost every day — in API responses, configuration files, log lines, and database records. This guide gives you a solid mental model of what JSON is, how it is built, and how to reason about it, with plenty of examples you can try in the JSON Wallet editor as you read.
A short history: why JSON exists
JSON was popularised by Douglas Crockford in the early 2000s, drawn directly from the object and array syntax of JavaScript. Before it, the dominant format for exchanging data was XML, which is powerful but verbose. Developers wanted something simpler that mapped cleanly onto the data structures they already used in code. JSON fit perfectly: a JSON object looks almost exactly like a JavaScript object, and parsing it is trivial. It was later standardised as ECMA-404 and RFC 8259, which means the grammar is fixed and unambiguous across every language and library.
What JSON looks like
A JSON document is just text that follows a small set of rules. Here is a typical example describing a user:
{
"id": 42,
"name": "Ada Lovelace",
"email": "ada@example.com",
"isActive": true,
"roles": ["admin", "editor"],
"profile": {
"city": "London",
"joined": "2026-01-15"
},
"lastLogin": null
}Even if you have never seen JSON before, you can probably read that. It maps keys (like "name") to values (like "Ada Lovelace"), and values can themselves be lists or nested objects.
The building blocks
JSON is built from just two container structures and a handful of value types:
- Objects — an unordered set of key/value pairs wrapped in curly braces
{ }. Keys are always strings in double quotes. - Arrays — an ordered list of values wrapped in square brackets
[ ]. - Strings — text in double quotes, e.g.
"hello". - Numbers — integers or decimals, e.g.
42or3.14. - Booleans —
trueorfalse. - null — represents an empty or unknown value.
Objects and arrays can be nested inside one another to any depth, which is what lets JSON describe complex, real-world data — a list of orders, each containing a customer object, which in turn contains an array of addresses, and so on.
Objects vs arrays: when to use which
A common beginner question is when to reach for an object versus an array. The rule of thumb: use an object when each piece of data has a distinct, named meaning (a person has a name, an age, an email), and use an array when you have a collection of similar things whose order may matter (a list of people, a list of tags). They combine naturally:
{
"team": "Platform",
"members": [
{ "name": "Ada", "role": "lead" },
{ "name": "Grace", "role": "engineer" }
]
}Where you will encounter JSON
- Web APIs — when an app fetches data from a server, the response is almost always JSON. The browser
fetch()API returns it, andresponse.json()parses it. - Configuration files — tools like npm (
package.json), TypeScript (tsconfig.json), and many others store settings as JSON. - Databases — document databases such as MongoDB store records in a JSON-like format, and most SQL databases now have native JSON column types.
- Logs and analytics — structured logs are frequently emitted as one JSON object per line (newline-delimited JSON, or NDJSON).
- Message queues and webhooks — services like Stripe, GitHub and Slack send event payloads as JSON.
JSON is data, not code
A crucial point for newcomers: JSON describes data, not behaviour. It cannot contain functions, comments, variables, or logic. This restriction is a feature — it makes JSON safe to parse, because a JSON parser never executes anything. (Historically some JavaScript code used eval() to parse JSON, which was a serious security risk. Always use a real parser such as JSON.parse() instead.)
A quick note on data types
JSON has no separate types for dates, integers vs floats, or large numbers. Dates are conventionally stored as ISO-8601 strings ("2026-01-15T08:30:00Z"). All numbers are double-precision floats, so very large integers (beyond about 2^53) can lose precision — IDs that big are usually sent as strings instead. Knowing these conventions saves you from subtle bugs later.
Why JSON won
JSON took over from XML because it is dramatically less verbose, maps directly onto the data structures (objects and arrays) that programmers already use, and is trivial to parse. The result is smaller payloads, faster parsing, and code that is easier to read. It hits a sweet spot: structured enough for machines, readable enough for humans.
Frequently asked questions
Is JSON only for JavaScript?
No. The name is historical. Python, Java, Go, Rust, C#, PHP, Ruby and virtually every other language ship with JSON support, either built in or via a standard library. JSON is one of the most language-neutral formats in existence.
What is the difference between JSON and a JavaScript object?
A JavaScript object is an in-memory data structure in a running program; JSON is a text format. JSON also has stricter rules: keys must be double-quoted, no trailing commas, no comments, and no functions or undefined values. Every valid JSON document is valid JavaScript, but not the reverse.
What file extension and media type does JSON use?
JSON files use the .json extension, and the official MIME type is application/json. APIs set this in the Content-Type header so clients know how to interpret the body.
Try it yourself
The best way to understand JSON is to work with it. Paste the examples above into the JSON Wallet editor and switch to the tree view to explore their structure interactively. When you are ready to go deeper, read our guide on the exact syntax rules of JSON, or learn how to parse JSON in code.
Keep reading
JSON Syntax Rules Explained (With Examples)
JSON has a small but strict grammar. This reference walks through every rule with valid and invalid examples so your data parses the first time.
Common JSON Errors and How to Fix Them
Every developer hits "Unexpected token in JSON" eventually. Here are the most common JSON errors, what causes them, and exactly how to fix each one.
JSON vs XML vs YAML: A Practical Comparison
JSON, XML and YAML all store structured data, but each suits different jobs. See the same data in all three and learn when to reach for which.
Ready to put this into practice? Open the free JSON editor →