JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging structured data. It was standardised in RFC 8259 and is now the default data format for REST APIs, configuration files, databases, and practically everything that passes data between systems.

JSON was created by Douglas Crockford in 2001, who described the format at json.org after using it with Chip Morningstar at State Software. It was later formalised independently by Ecma International (ECMA-404) and the IETF (RFC 8259, linked above), which is why you'll see both cited as the JSON spec. Despite its JavaScript origins, JSON is completely language-agnostic: every major programming language can read and write it natively.

The 6 JSON data types

JSON supports exactly six value types. Nothing else is valid.

string
"Hello""2024-01-31"""

Always double-quoted. Single quotes are invalid.

number
423.14-71.5e10

Integer or float, IEEE 754 double. No NaN, no Infinity, no hex.

boolean
truefalse

Lowercase only. True and False are invalid.

null
null

Represents the intentional absence of a value.

array
[1, 2, 3]["a", "b"][]

Ordered list of any JSON values. Can be mixed types.

object
{"key": "val"}{}

Unordered key-value pairs. Keys must be strings.

Numbers are unbounded in the spec, but most parsers store them as IEEE 754 double-precision floats, including JavaScript's Number type. That's exact for integers only up to 253. See JSON best practices for how to handle IDs larger than that.

Nesting objects and arrays

Any JSON value can contain any other JSON value, so objects and arrays nest freely to whatever depth you need — the only real limit is your parser's call stack. A typical API response combines several layers: an object holding a nested object, plus an array of objects.

{
  "id" 1024
  "customer" {
    "name" "Alice"
    "vip" true
  }
  "items" [
    { "sku" "A1" "qty" 2 }
    { "sku" "B7" "qty" 1 }
  ]
}

Syntax rules

JSON has a small, strict set of rules. Break any one of them and the document is invalid.

Keys must be double-quoted strings
✅ valid{"name": "Alice"}
❌ invalid{name: "Alice"}
Strings use double quotes only
✅ valid"hello"
❌ invalid'hello'
No trailing commas
✅ valid{"a": 1, "b": 2}
❌ invalid{"a": 1, "b": 2,}
No comments
✅ valid{"rate": 0.15}
❌ invalid{"rate": 0.15} // VAT
Numbers have no leading zeros
✅ valid{"code": 7}
❌ invalid{"code": 007}
No undefined, NaN, or Infinity
✅ valid{"val": null}
❌ invalid{"val": undefined}

JSON vs XML

Before JSON, XML dominated data exchange. Here is the same data in both formats.

JSON 59 chars
{
  "name" "Alice"
  "age" 30
  "admin" true
  "tags" ["dev" "ops"]
}
XML 104 chars
<user>
  <name>Alice</name>
  <age>30</age>
  <admin>true</admin>
  <tags>
    <tag>dev</tag>
    <tag>ops</tag>
  </tags>
</user>
JSONXML
VerbosityCompactVerbose
Native typesnumber, boolean, null, arrayStrings only (attributes aside)
CommentsNot supportedSupported
Schema validationJSON SchemaXSD, DTD
Human-readableEasyCluttered with tags
Parse speedFastSlower
Still used forAPIs, config, storageSOAP, SVG, Office docs

Where JSON is used

REST APIs
The standard format for request and response bodies. Every HTTP client and server library speaks JSON.
Content-Type: application/json
⚙️
Configuration files
Package manifests, IDE settings, and tool configs use JSON for its simplicity and wide tooling support.
package.json, tsconfig.json, .eslintrc
🗄️
Databases
Document databases like MongoDB store records as JSON. PostgreSQL and MySQL have native JSON column types.
db.users.find({ active: true })
💾
Browser storage
localStorage and sessionStorage only store strings — JSON.stringify/parse bridges the gap for objects.
localStorage.setItem("prefs", JSON.stringify(obj))

This site's JSON Formatter validates and beautifies any JSON document instantly, without leaving the browser.

Frequently asked questions

JSON (JavaScript Object Notation) was inspired by JavaScript object literal syntax, but it is an independent, language-agnostic format defined by RFC 8259.

Every major programming language has JSON support built in or available via a standard library: Python (json module), Java (Jackson, Gson), PHP (json_encode/json_decode), Go (encoding/json), Rust (serde_json), and so on.