What is JSON?
JSON (JavaScript Object Notation) is a text-based data format used to represent structured data. It’s the de facto standard for REST APIs, config files, data storage, and inter-process communication.
Despite the name, JSON is language-independent. Every major programming language has a JSON library. The syntax was derived from JavaScript object literals, but that’s where the relationship ends — JSON is just a format.
A Minimal Example
{
"id": 42,
"name": "Alice Chen",
"active": true,
"score": 98.5,
"tags": ["developer", "typescript"],
"address": null
}This is valid JSON. It demonstrates all six data types: number, string, boolean, array, object, and null.
Where JSON Came From
Douglas Crockford formalized JSON in the early 2000s as a lighter alternative to XML for AJAX data interchange. It became the dominant format because it’s readable, compact, and trivially parseable. RFC 8259 (2017) is the current specification.
JSON vs XML
XML dominated structured data exchange through the 1990s and 2000s. JSON replaced it for most HTTP APIs because:
- Significantly less verbose — no closing tags, no attributes
- Maps directly to native data structures in most languages
- Faster to parse in practice
- Easier to write by hand
XML still wins for document-centric content (HTML is XML-adjacent), namespaces, and complex schemas.
JSON vs YAML
YAML is a superset of JSON. All valid JSON is valid YAML. YAML is preferred for config files because it supports comments, multi-line strings, and anchors. JSON is preferred for APIs because it’s stricter and easier to parse deterministically.
Tools
- JSON Formatter — format and validate JSON
- JSON Syntax Guide — detailed syntax reference
- JSON Data Types — all six types explained
- Common JSON Errors — fix parse errors