JSON is the universal language of the web. Whether you are building apps, calling APIs, or storing data, you will encounter JSON everywhere. This guide explains JSON from scratch with clear examples.
Try JSON Validator →JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for representing structured data. Despite having "JavaScript" in the name, JSON is completely language-independent — it is used in Python, Java, Go, Ruby, PHP, Swift, Rust, and virtually every other programming language.
JSON was created by Douglas Crockford in the early 2000s and standardized in RFC 4627 (2006) and later RFC 8259 (2017). It was designed to be easy for both humans to read and machines to parse.
Here is the simplest possible JSON object:
{
"name": "Alice",
"age": 30,
"city": "London"
}
You can probably read that without any training. That readability is one of JSON's greatest strengths.
JSON supports exactly six data types. Understanding them is the foundation of working with JSON.
A sequence of Unicode characters enclosed in double quotes. Single quotes are not allowed in JSON.
"Hello, world!"
"user@example.com"
"2026-03-05"
An integer or floating-point number. JSON does not distinguish between integer and float — both are simply "number". There is no separate type for dates, hex values, or infinity.
42
3.14159
-7
1.5e10
Either true or false, written in lowercase. These are not strings — they have no quotes.
true
false
Represents the intentional absence of a value. Written as lowercase null with no quotes.
null
An ordered list of values enclosed in square brackets, separated by commas. An array can contain any mix of data types, including other arrays or objects.
["apple", "banana", "cherry"]
[1, 2, 3, 4, 5]
[true, null, 42, "mixed"]
An unordered collection of key-value pairs enclosed in curly braces. Keys must be strings (in double quotes). Values can be any JSON type. Objects can be nested inside other objects or arrays.
{
"id": 1,
"active": true,
"tags": ["admin", "user"],
"address": {
"street": "10 Downing St",
"country": "UK"
}
}
JSON has a small, strict set of syntax rules. These are the most common rules beginners get wrong:
"name": "Alice" is correct. name: "Alice" is not.{"a":1,} is invalid.// this is wrong inside JSON is a syntax error.') are not valid in JSON.True, False, NULL are invalid. Use true, false, null.NaN, Infinity, and -Infinity are not valid JSON numbers.Here is a valid and invalid comparison:
// INVALID JSON (common mistakes)
{
name: "Alice", // key not in quotes
'city': 'London', // single quotes
age: 30, // trailing comma after last item
active: True // capital T
}
// VALID JSON
{
"name": "Alice",
"city": "London",
"age": 30,
"active": true
}
JSON is not the only data format — but it is the most popular for web APIs. Here is how it compares to the other major formats:
| Feature | JSON | XML | YAML |
|---|---|---|---|
| Human readable | Good | Verbose | Excellent |
| Comments | No | Yes | Yes |
| File size | Compact | Large | Compact |
| Native browser support | Yes | Yes | No |
| Best for | APIs, data | Documents | Config files |
For a deeper comparison between JSON and YAML specifically, see our JSON vs YAML guide.
JSON is everywhere in modern software development. Here are the most common places you will encounter it:
When your browser or app requests data from a server — whether loading your Twitter feed, checking the weather, or submitting a payment — the server almost always responds with JSON. It is the default format for REST APIs. The request body is JSON, and the response body is JSON.
package.json in Node.js projects, tsconfig.json for TypeScript, manifest.json for browser extensions, appsettings.json in .NET — JSON is the dominant format for application configuration files.
Modern databases support storing and querying JSON directly. PostgreSQL has a native jsonb column type. MySQL has JSON columns. MongoDB stores documents as BSON (Binary JSON). Firebase and Firestore are built entirely around JSON-style documents.
Microservices communicate over HTTP or message queues, and the messages are almost always JSON. Event-driven architectures (Kafka, SQS, Pub/Sub) publish and consume JSON events. Webhooks send JSON payloads to your endpoints.
Browser LocalStorage and SessionStorage only store strings. Developers use JSON.stringify() to serialize objects before storing and JSON.parse() to restore them. Service workers, IndexedDB, and the Web Storage API all work closely with JSON.
Reading JSON is straightforward once you recognize the two container types — objects (curly braces) and arrays (square brackets). Here is a real-world example of a JSON API response:
{
"status": "success",
"user": {
"id": 42,
"name": "Alice Chen",
"email": "alice@example.com",
"roles": ["admin", "editor"],
"preferences": {
"theme": "dark",
"notifications": true
},
"lastLogin": "2026-03-05T10:30:00Z"
}
}
Reading this step by step:
{} is the root object"status" is a string key with the string value "success""user" is a key whose value is a nested object"id" is a number (42), no quotes needed"roles" is an array of strings: ["admin", "editor"]"preferences" is another nested object with a boolean value"notifications": true is a boolean, not the string "true"To access a value in code, you navigate the path. In JavaScript: data.user.preferences.theme gives you "dark". In Python: data["user"]["preferences"]["theme"].
JSON stands for JavaScript Object Notation. It was derived from JavaScript object syntax but is now a fully language-independent standard used in every major programming language. The official specification is IETF RFC 8259.
JSON supports exactly six data types: string (text in double quotes), number (integer or decimal), boolean (true or false), null (no value), array (ordered list in square brackets), and object (key-value pairs in curly braces). There is no date type, no undefined, and no binary type in JSON.
For most modern web API use cases, yes. JSON is more compact, easier to read, and natively supported by JavaScript. XML has advantages for document-oriented data, complex namespacing, and when an existing XML schema or toolchain already exists. However, for REST APIs and data exchange between web services, JSON is the overwhelming industry standard today.
Paste your JSON into the free validator at JSON Web Tools. The validator checks every syntax rule: quoted keys, correct comma placement, no trailing commas, valid value types, and properly nested brackets. It shows the exact line and character position of any error so you can fix it quickly.
Paste any JSON and validate it instantly. Free, private, no account needed.
Try JSON Validator →Also useful: JWT Decoder | JSON Flatten Tool | JSON Key Sorter | Base64 JSON Tool | JSON vs YAML