What is JSON?
5 min read · Developer fundamentals
The short answer
JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for storing and exchanging data. Despite its name, JSON is completely language-independent — it is used by virtually every modern programming language including Python, Java, Go, Ruby, PHP, and of course JavaScript.
JSON was introduced by Douglas Crockford in the early 2000s as a simpler alternative to XML. Today it is the dominant data format for web APIs, configuration files, and data storage.
JSON syntax rules
JSON has six simple rules:
- Data is written as key/value pairs
- Keys must be double-quoted strings
- Data is separated by commas
- Objects use curly braces {}
- Arrays use square brackets []
- No trailing commas and no comments allowed
JSON data types
JSON supports exactly six data types:
| Type | Example | Notes |
|---|---|---|
| string | "hello" | Always double quotes |
| number | 42, 3.14 | No distinction between int/float |
| boolean | true, false | Lowercase only |
| null | null | Represents absence of value |
| object | {} | Unordered key/value pairs |
| array | [] | Ordered list of values |
A real JSON example
Here is a JSON object representing a user profile:
{
"id": 1042,
"name": "Ana García",
"email": "ana@example.com",
"age": 28,
"isPremium": true,
"address": {
"city": "Madrid",
"country": "Spain"
},
"tags": ["developer", "designer"],
"avatar": null
}Common use cases
- REST APIs — virtually all modern web APIs send and receive JSON
- Configuration files — package.json, tsconfig.json, .eslintrc
- Databases — MongoDB, PostgreSQL JSONB, Firebase all store JSON natively
- Data exchange — between microservices, between frontend and backend
- Local storage — browsers store data as JSON strings in localStorage
JSON vs XML
Before JSON, XML was the standard for data exchange. JSON replaced XML in most web contexts because it is easier to read, shorter to write, and faster to parse. A JSON object with three fields takes roughly half the characters of the equivalent XML.
XML is still used in some industries (finance, healthcare, enterprise) and for documents with complex metadata, but for web APIs and application data, JSON is the clear standard.
Common JSON mistakes
- Using single quotes instead of double quotes for strings or keys
- Adding a trailing comma after the last item in an object or array
- Adding comments — JSON does not support comments
- Using undefined as a value — it is not a valid JSON type
- Forgetting to quote keys — unlike JavaScript objects, all JSON keys must be quoted
Try it yourself
Use our free JSON tools to format, validate, and explore JSON data.