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
}People Also Ask
What does JSON stand for?
JSON stands for JavaScript Object Notation. It is a lightweight, text-based data format used to store and exchange structured data between systems.
What is JSON used for?
JSON is used as the primary data format for web APIs (REST APIs), configuration files, database storage (MongoDB, DynamoDB), and data exchange between services. Almost every modern web application sends and receives data as JSON.
Is JSON a programming language?
No. JSON is a data format, not a programming language. It is a way to represent structured data as text so it can be transmitted between systems. It was derived from JavaScript syntax but is language-independent.
What is the difference between JSON and XML?
JSON is lighter and more readable than XML. JSON uses key-value pairs and arrays; XML uses opening and closing tags. JSON files are typically 20-30% smaller than equivalent XML. JSON has largely replaced XML for web APIs, though XML is still used in SOAP, RSS, and some enterprise systems.
Is JSON case sensitive?
Yes. Keys and string values in JSON are case-sensitive — "Name" and "name" are treated as two different keys. Reserved literals (true, false, null) must also be lowercase; True or NULL are invalid JSON.
Can JSON have comments?
No. The JSON specification (RFC 8259) has no syntax for comments — neither // nor /* */. Some parsers accept a relaxed superset like JSON5 or JSONC that allows comments, but standard JSON does not.
What is a JSON Schema?
JSON Schema is a specification for describing the structure of JSON data — which fields are required, their types, and validation rules. It's used to validate API payloads and generate documentation, similar to how XML Schema (XSD) validates XML.
How big can a JSON file be?
There's no limit defined by the JSON spec itself — the practical limit depends on the parser and available memory. Browsers and most languages handle files up to several hundred MB without issue; very large datasets are usually streamed or paginated instead of loaded as one JSON document.
Try the Free JSON Beautifier
Paste any JSON and instantly get a readable, validated, formatted version.
Open JSON Beautifier