Programming · data · web
What is JSON?
Open almost any web API response, a JavaScript config file, or a modern app's saved settings, and you will see JSON. It is the format that quietly carries most of the structured data moving around the internet. This guide explains what JSON is, its small syntax, why it took over, how it compares to XML, and where it falls short.
The short definition
JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It is easy for humans to read and easy for machines to parse, and despite the name it is language-independent — practically every programming language can read and write it.
The syntax, in one example
JSON is built from a handful of value types: objects, arrays, strings, numbers, booleans and null. An object is a set of key–value pairs in braces; an array is an ordered list in brackets:
{
"name": "Ada",
"age": 36,
"active": true,
"roles": ["admin", "author"],
"address": { "city": "London", "zip": "EC1" }
} That is essentially the whole format. Keys are always strings in double quotes; values can themselves be objects or arrays, so JSON nests to any depth. There are no functions, no variables and no logic — it describes data, nothing more.
Why JSON is everywhere
- APIs speak it. When an app asks a server for data, the reply is almost always JSON. It maps cleanly onto the objects and arrays every language already has.
- It is human-readable. You can open a JSON response and understand it without tools, which makes debugging far easier than binary formats.
- It is tiny and universal. The spec is small, every language ships a JSON parser, and the format adds little overhead.
- Config files use it. From
package.jsonto countless tool settings, JSON is a common way to store configuration.
JSON vs XML
Before JSON, XML was the common data-exchange format. XML is more verbose — every value is wrapped in opening and closing tags — and supports features like attributes, namespaces and schemas that JSON does not. JSON won for web APIs because it is lighter, less noisy, and maps directly onto JavaScript objects in the browser. XML still has its place where its richer document features matter; for most data exchange, JSON is the default.
The honest limits
JSON's simplicity has trade-offs. It has no comments, so you cannot annotate a config file inline. It has no date type — dates are passed as strings by convention. It has no schema built in (though tools like JSON Schema add one separately), and large JSON documents are less efficient than purpose-built binary formats. For most web data, none of this matters; for very large or strongly-typed data, it is worth knowing.
FAQ
Is JSON only for JavaScript? No. The name comes from JavaScript syntax, but JSON is language-independent — Python, Go, Rust, Java and the rest all read and write it natively.
What is the difference between JSON and a JavaScript object? They look similar, but JSON is a text format (a string); a JavaScript object is a live in-memory value. You parse JSON text into an object, and stringify an object back into JSON.
Can JSON store comments? No. The format deliberately omits comments. Some tools accept "JSON with comments" variants, but standard JSON does not.
How are dates handled in JSON? As strings, by convention — usually ISO 8601 like "2026-06-14". JSON itself has no dedicated date type.
JSON is the data half of most web communication; the request-and-response machinery around it is the API. Browse more clear explainers in our guides index.