What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used to store and exchange structured data. It is the universal language of APIs — almost every web service sends and receives data as JSON. This guide explains what JSON is, how it works, and why it matters.
// JavaScript object (NOT JSON)
const user = {
name: 'Alice',
age: 30,
active: true
}JSON in Plain English
JSON is a way to represent data as text so it can be sent between systems — between a server and a browser, between two microservices, or stored in a file. It was derived from JavaScript object syntax but is completely language-independent: Python, Go, Java, Ruby, and virtually every other language has built-in JSON support.
JSON was defined in RFC 8259 and is the most widely used data interchange format in software today, having largely replaced XML for web APIs.
JSON Syntax Rules
"name": "Alice""key": value"active": true{"name": "Alice"}["red", "green", "blue"]{"a": 1, "b": 2}// this would break JSONJSON Data Types
JSON supports exactly 6 data types:
"name": "Alice"Must use double quotes"age": 30Integer or float, no quotes"active": truetrue or false, lowercase"nickname": nullRepresents no value"address": { "city": "NYC" }Nested key-value pairs"tags": ["web", "api"]Ordered list of valuesJSON vs XML — Why JSON Won
Before JSON, XML was the dominant data exchange format for web APIs (SOAP, RSS, etc.). JSON replaced it for most use cases because:
XML is still used in specific domains — SOAP APIs, RSS/Atom feeds, SVG, and some enterprise systems. But for modern REST APIs, JSON is the standard.
A Real-World JSON Example
Here is what a typical REST API response looks like — a user object with nested address and an array of roles:
{
"id": 1042,
"name": "Alice Johnson",
"email": "[email protected]",
"age": 30,
"active": true,
"address": {
"street": "123 Main St",
"city": "New York",
"country": "US"
},
"roles": ["admin", "editor"],
"lastLogin": null
}Try the Free JSON Beautifier
Paste any JSON and instantly get a readable, validated, formatted version.
Open JSON Beautifier