Skip to main content

Data formats

What is JSON?

Definition

JSON is a text format for structured data built from objects, arrays, strings, numbers, booleans and null, and it is the default payload format of web APIs.

Also known as: JavaScript Object Notation

JSON in more detail

JSON took the object literal syntax of JavaScript, threw away everything that could execute, and became the interchange format for almost everything. It has exactly six value types — object, array, string, number, boolean, null — and a grammar small enough to fit on one page, which is why every language ships a parser and why two systems written decades and continents apart can exchange data without negotiating.

The strictness catches people out. Keys must be double-quoted strings, single quotes are invalid, trailing commas are invalid, and comments do not exist — which is why JSON is a poor configuration format and why JSON with Comments and JSON5 exist as separate things. There is no date type either, so timestamps travel as ISO 8601 strings by convention, not by specification.

Numbers are the sharpest edge. JSON does not define a precision, and most parsers map numbers to IEEE 754 doubles, so any integer beyond 2^53 loses accuracy in transit. A 64-bit database id or a Twitter-style snowflake sent as a bare number can come back subtly wrong, which is why careful APIs send large ids as strings.

JSON example

{
  "id": "9007199254740993",
  "name": "Ada Lovelace",
  "active": true,
  "score": 91.5,
  "tags": ["engineering", "notes"],
  "manager": null,
  "created_at": "2026-03-04T09:15:00Z"
}

Invalid JSON, all common mistakes:
  { name: "Ada" }           key not quoted
  { 'name': 'Ada' }         single quotes
  { "a": 1, }               trailing comma
  { "a": 1 } // comment     comments not allowed

JSON — common questions

Is JSON the same as a JavaScript object?
No. JSON is a text format; a JavaScript object is a value in memory. JSON is also stricter — it has no functions, no undefined, no comments, and requires double-quoted keys, all of which JavaScript object literals allow.
Can JSON store dates?
Not natively. There is no date type, so the convention is an ISO 8601 string such as 2026-03-04T09:15:00Z. Both sides have to agree to parse it, since the format itself makes no promise about what that string means.
Why do some APIs send IDs as strings?
To avoid precision loss. Most JSON parsers read numbers as 64-bit floats, which cannot represent every integer above 9,007,199,254,740,991 exactly, so a large numeric id can change value simply by being parsed. Quoting it keeps it intact.

Keep reading

This page explains what JSON means. For the syntax itself, the JSON cheat sheet is a full reference of real commands and examples. Every other definition is in the A-Z glossary.

Browse the A-Z glossary