⌘K

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

TypeLooks likeNotes
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
Number42, -3.5, 1e6No leading +, no NaN, no Infinity
Booleantrue / falseLowercase only
NullnullRepresents 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

JSONXMLYAML
Best forAPIs, config, storageDocuments, enterprise messagingHuman-edited config
VerbosityLowHighLowest
CommentsNoYesYes
SchemaJSON SchemaXSD / DTDJSON Schema (via conversion)

JSON Formatter

Paste any JSON to beautify, minify and validate it — entirely in your browser.

Try JSON Formatter

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

A typical API response using every JSON data type
{
  "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

All terms

Related tools

Related guides

All guides