{ }jsonkitOpen the tool

What Is JSON? A Beginner’s Guide to JavaScript Object Notation

6 min read · updated 2026-07-12

JSON (JavaScript Object Notation) is the most widely used data-interchange format on the web. When your phone loads a weather app, when two microservices talk to each other, or when a config file tells a program how to behave, there's a good chance JSON is carrying that data.

This guide explains JSON from the ground up: where it came from, the six value types it supports, what a real JSON document looks like, and how to read and validate it. No prior experience with JSON is assumed — only a little familiarity with programming ideas like text files and key-value pairs.

What Is JSON, Exactly?

JSON stands for JavaScript Object Notation. It is a text-based format for representing structured data as key-value pairs and ordered lists. Because it's just plain text, a JSON document is human-readable, easy to store in a file, and simple to send over a network.

The core idea: almost any piece of structured information — a user profile, a shopping cart, a sensor reading — can be described with two building blocks. Objects are collections of named values, written with curly braces {}. Arrays are ordered lists of values, written with square brackets []. Nest these together and you can model surprisingly complex data with a format simple enough to read at a glance.

Here is the smallest useful example — an object with two fields:

A JSON object with a string field and a number field.json
{
  "name": "Ada",
  "age": 36
}

The key point for beginners: JSON is a *format*, not a programming language. You don't write logic in it. You use it to describe data that a program then reads (parses) or writes (serializes).

A Short History: From JavaScript to Universal Standard

JSON was specified by Douglas Crockford in the early 2000s. It wasn't invented in a lab so much as noticed in the wild: developers were already passing data between browser and server using a subset of JavaScript's object-literal syntax, because a browser could turn that text back into live objects cheaply. Crockford formalized the rules, named the format, and published a specification at json.org.

At the time, XML dominated data interchange. XML was powerful but verbose, and parsing it in a browser was clunky. JSON offered the same nesting capability with a fraction of the syntax and a parser that mapped directly onto native data structures. It spread quickly alongside the rise of AJAX-driven web apps in the mid-2000s.

Crucially, JSON was standardized so it wouldn't depend on JavaScript at all. It's defined by ECMA-404 and RFC 8259, and every mainstream language now ships a JSON parser. The name still says "JavaScript," but JSON is genuinely language-independent — Python, Go, Rust, Java, and C# all read and write it natively.

The Six JSON Value Types

Every value in a JSON document is one of exactly six types. Learn these and you've learned most of the format. For a deeper treatment with edge cases, see the JSON data types guide.

TypeExampleNotes
String"hello"Text in double quotes only. Supports escapes like \n and \".
Number42, -3.14, 2.5e6One numeric type — no int/float distinction, and no NaN or Infinity.
Booleantrue, falseLowercase only.
NullnullRepresents an empty or missing value.
Object{ "key": value }Set of string-keyed pairs; treated as unordered.
Array[1, 2, 3]Ordered list; values may be mixed types.

Rules that trip up beginners

  • Keys and string values must use double quotes — single quotes are invalid JSON.
  • There are no trailing commas. [1, 2, 3,] is a syntax error.
  • Comments are not allowed in standard JSON.
  • Numbers can't have leading zeros or a bare leading/trailing decimal point (.5, 5., and 01 are all invalid).

A Complete Annotated Example

Here's a realistic document that combines all six value types — an object describing a user, with nested objects and an array:

A user record using strings, numbers, booleans, null, arrays, and nested objects.json
{
  "id": 1042,
  "username": "ada.lovelace",
  "isActive": true,
  "middleName": null,
  "roles": ["admin", "editor"],
  "profile": {
    "displayName": "Ada Lovelace",
    "loginCount": 87,
    "lastLogin": "2026-07-01T09:30:00Z"
  },
  "tags": []
}

Reading top to bottom: id is a number, username a string, isActive a boolean, and middleName is explicitly null (the user has no middle name). roles is an array of strings. profile is a nested object — objects can contain other objects to any depth. Note that lastLogin is a string: JSON has no date type, so timestamps are conventionally stored as ISO 8601 strings. Finally, tags is an empty array, which is perfectly valid.

Where JSON Is Used

JSON's simplicity made it the default choice across modern software. The four places you'll meet it most often:

Web APIs

Most REST APIs send and receive JSON. When an app requests data, the server responds with a JSON body; when the app submits a form, it often posts JSON. The Content-Type: application/json header signals this.

Configuration files

Tools like npm (package.json), TypeScript (tsconfig.json), and countless others store settings as JSON — structured enough for nested options, yet simple enough to hand-edit.

Logs and events

Structured logging systems emit one JSON object per line (a format called NDJSON) so machines can filter and query logs by field instead of grepping raw text.

NoSQL databases

Document databases like MongoDB store records as JSON-like documents, letting each record carry its own nested structure without a rigid table schema.

JSON vs XML: Why JSON Won

Both formats represent nested, structured data as text, but they make different trade-offs. The same data shows the gap:

XML: every value is wrapped in an opening and closing tag.xml
<user>
  <name>Ada</name>
  <age>36</age>
</user>

The JSON equivalent ({"name": "Ada", "age": 36}) carries the same information in far fewer characters, and it maps directly onto the objects and arrays that programming languages already use. XML still shines where documents need attributes, namespaces, mixed content, or schema validation via XSD — but for API payloads and config, JSON's lighter weight usually wins. For a full breakdown, see JSON vs XML.

How to Read and Validate JSON

Because JSON's syntax rules are strict, a single misplaced comma or missing quote breaks the whole document. The fastest way to catch these is a validator, which parses the text and reports the exact location of the first error.

JSON ValidatorOpen the tool

In code, "reading" JSON means parsing the text into a native data structure. In JavaScript this is built in:

Parsing and serializing JSON in JavaScript with JSON.parse and JSON.stringify.js
const text = '{"name": "Ada", "roles": ["admin", "editor"]}';

// Parse JSON text into a JavaScript object
const user = JSON.parse(text);
console.log(user.name);       // "Ada"
console.log(user.roles[0]);   // "admin"

// Serialize a JavaScript object back into JSON text
const output = JSON.stringify(user, null, 2);
console.log(output);

JSON.parse turns text into an object you can work with; JSON.stringify does the reverse (the 2 argument pretty-prints with 2-space indentation). Every major language has an equivalent — see Working with JSON in Python for the json module version. When a parse fails, a validator tells you *where*, and from there the fix is usually quick.

Frequently asked questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. It's a text-based format for storing and exchanging structured data, and despite the name it works with every major programming language, not just JavaScript.

Is JSON a programming language?

No. JSON is a data format, not a language. You can't write logic, loops, or functions in it. It only describes data — objects, arrays, and values — that a program then reads or writes.

What are the six data types in JSON?

String, number, boolean, null, object, and array. Every value in a JSON document is one of these six types. Notably, there is no separate date type; dates are usually stored as ISO 8601 strings.

Can JSON have comments?

Standard JSON does not allow comments, so adding // or /* */ makes the document invalid. Variants like JSONC and JSON5 support comments for config files, but strict JSON parsers reject them.

What's the difference between JSON and a JavaScript object?

They look similar, but JSON is stricter: keys and strings must use double quotes, no trailing commas are allowed, and comments are forbidden. A JavaScript object literal permits all of those, so it isn't always valid JSON.

How do I check if my JSON is valid?

Paste it into a validator, which parses the text and reports the exact line of the first error. In code, calling JSON.parse (JavaScript) or json.loads (Python) throws an error if the JSON is malformed.