What is JSON (JavaScript Object Notation)?

JSON is a lightweight, human-readable data format built from key-value pairs and arrays, and it is the default language of web APIs.

JSON, or JavaScript Object Notation, is a text format for representing structured data using two universal building blocks: objects (unordered collections of key-value pairs wrapped in curly braces) and arrays (ordered lists wrapped in square brackets). Values can be strings, numbers, booleans, null, or nested objects and arrays. This small, consistent grammar is why JSON became the standard payload format for almost every modern web API.

JSON's popularity comes from being both human-readable and trivial for machines to parse. Unlike XML, it has no closing tags or attributes to reason about, and unlike CSV, it can represent nested and hierarchical data naturally. A single JSON document can describe a user, their list of orders, and the line items within each order without any ambiguity about structure.

There are strict rules that trip people up. Keys and string values must use double quotes - single quotes are invalid - trailing commas are not allowed, and comments are not part of the specification. These constraints make JSON predictable but unforgiving, so a validator or formatter is invaluable when hand-editing configuration or API request bodies.

In day-to-day work, JSON is the connective tissue between systems. You convert CSV lead lists to JSON to POST them to an API, transform JSON API responses to CSV for a spreadsheet, or reformat minified JSON into an indented view to read it. Related formats like YAML and TOML trade some of JSON's strictness for readability, and structured data on the web is frequently expressed as JSON-LD.

Examples

  • {"name":"Ada","active":true,"roles":["admin","editor"]}
  • An array of objects: [{"id":1},{"id":2}] - the shape most APIs return for lists
  • null, true, and 42 are all valid standalone JSON values

Common questions

Why is my JSON invalid?
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, and comments. A JSON validator will point to the exact line and character where parsing failed.
What is the difference between JSON and a JavaScript object?
JSON is a text format inspired by JavaScript syntax, but it is stricter - keys must be quoted strings and only specific value types are allowed. A JavaScript object is a live in-memory structure that can contain functions and undefined.
Should I minify JSON?
Minify it for transmission to save bandwidth, and pretty-print it for reading and debugging. Tools can convert instantly between the two without changing the data.

Related tools

Related terms for JSON (JavaScript Object Notation)