Data Formats
JSON
JSON is a lightweight text-based data format commonly used to exchange structured data between applications and APIs.
Updated 12 Aug 2026
How JSON works
JSON (JavaScript Object Notation) stores data as nested key/value pairs and ordered lists. A document is plain UTF-8 text, so it can travel over HTTP, sit in a log line, live in a database column or be saved as a .json file. Any language with a JSON parser — Python, Go, Java, PHP, Rust, every browser — reads the same bytes the same way, which is why it replaced heavier formats for most web APIs.
The whole specification fits on a page. A JSON value is one of six things: an object, an array, a string, a number, a boolean or null. Objects wrap key/value pairs in braces, arrays wrap ordered values in brackets, and keys are always double-quoted strings.
JSON syntax and data types
| Type | Looks like | Notes |
|---|---|---|
| Object | { "id": 1 } | Unordered key/value pairs; keys must be double-quoted |
| Array | ["a", "b"] | Ordered list; values may mix types |
| String | "hello" | Double quotes only, escape with backslash |
| Number | 42, -3.5, 1e6 | No leading +, no NaN, no Infinity |
| Boolean | true / false | Lowercase only |
| Null | null | Represents an intentionally empty value |
JSON is not JavaScript. Trailing commas, single quotes, comments, functions, dates and undefined are all valid JavaScript but invalid JSON — which is the source of most parse errors people hit in practice.
Common mistakes
Trailing commas
A comma after the last property or array element fails every strict parser.
Single quotes
'name' must be "name". JSON strings and keys require double quotes.
Comments
// and /* */ are not part of JSON. Move notes into a dedicated field or strip them before parsing.
Unescaped characters
Literal newlines, tabs and stray backslashes inside strings must be escaped as \n, \t and \\.
JSON vs XML vs YAML
| JSON | XML | YAML | |
|---|---|---|---|
| Best for | APIs, config, storage | Documents, enterprise messaging | Human-edited config |
| Verbosity | Low | High | Lowest |
| Comments | No | Yes | Yes |
| Schema | JSON Schema | XSD / DTD | JSON Schema (via conversion) |
JSON Formatter
Paste any JSON to beautify, minify and validate it — entirely in your browser.
Characteristics
- Plain UTF-8 text, readable without special software
- Six value types: object, array, string, number, boolean, null
- Language independent with parsers in every major runtime
- Strict syntax: double-quoted keys, no comments, no trailing commas
- Nested structures of any depth
Common uses
- REST and GraphQL API request and response bodies
- Application configuration files such as package.json or tsconfig.json
- Log lines and analytics events (newline-delimited JSON)
- Document databases like MongoDB and Postgres jsonb columns
- Browser storage and state serialisation
Advantages
- Small and fast to parse compared with XML
- Native support in JavaScript and first-class libraries everywhere else
- Easy to read and diff in version control
- Maps directly onto the data structures of most languages
Limitations
- No comments, so configuration files cannot be annotated
- No native date, binary or decimal types — everything becomes a string or number
- Large documents must usually be loaded fully into memory
- No built-in validation; you need JSON Schema for that
Examples
{
"id": 4821,
"name": "Ada Lovelace",
"active": true,
"score": 98.5,
"manager": null,
"roles": ["admin", "editor"],
"address": { "city": "London", "postcode": "NW1 6XE" }
}Frequently asked questions
What is JSON used for?
Mainly for moving structured data between systems: API payloads, configuration files, log events and stored documents.
Is JSON a programming language?
No. JSON is a data format. It has no logic, variables or functions — it only describes values.
What is the difference between JSON and XML?
JSON is terser and maps directly to native data structures, while XML supports attributes, namespaces and comments and suits document-centric use cases.
How can I validate JSON?
Paste it into a validator that reports the exact line and column of the first syntax error, then optionally check it against a JSON Schema.
Is JSON the same as a JavaScript object?
No. JSON is text with stricter rules — no single quotes, comments, trailing commas or functions.
Does JSON support comments?
Not in the standard. Formats such as JSONC and JSON5 add them, but standard parsers reject them.
Related terms
JSON Schema
JSON Schema is a declarative vocabulary, itself written in JSON, that describes the expected structure, types and constraints of a JSON document so it can be validated automatically.
XML
XML (Extensible Markup Language) is a text format that describes data using nested, self-labelled tags, designed for documents and long-lived system-to-system messaging.
YAML
YAML is a whitespace-indented data format designed to be written and read by people, most often used for configuration files such as CI pipelines and Kubernetes manifests.
CSV
CSV (Comma-Separated Values) is a plain-text table format where each line is a row and each field is separated by a delimiter, usually a comma.
API
An API (Application Programming Interface) is a defined contract that lets one piece of software request data or actions from another without knowing how it works internally.
SQL
SQL (Structured Query Language) is the standard language for defining, querying and modifying data held in relational databases.
Related tools
Related guides
What Is JSON? A Plain-English Guide
JSON explained without jargon: what it is, how the syntax works, which data types it supports, where it is used and how it differs from JavaScript objects.
How to Format JSON (Beautify, Indent and Minify)
Learn how JSON formatting works, see a before-and-after example, fix the errors that block beautifying, and format JSON online in your browser without uploading a file.
JSON vs XML: Which Format Should You Use?
A practical JSON vs XML comparison: syntax, size, parsing speed, schemas, comments, attributes and metadata — plus clear guidance on which format fits which job.
CSV vs JSON: Choosing the Right Data Format
Compare CSV and JSON on structure, nesting, file size, streaming, typing and tooling, with clear guidance on which to use for exports, APIs and analytics pipelines.