What is JSON? A Complete Guide for Beginners

JSON is the universal language of the web. Whether you are building apps, calling APIs, or storing data, you will encounter JSON everywhere. This guide explains JSON from scratch with clear examples.

Try JSON Validator →

What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for representing structured data. Despite having "JavaScript" in the name, JSON is completely language-independent — it is used in Python, Java, Go, Ruby, PHP, Swift, Rust, and virtually every other programming language.

JSON was created by Douglas Crockford in the early 2000s and standardized in RFC 4627 (2006) and later RFC 8259 (2017). It was designed to be easy for both humans to read and machines to parse.

Here is the simplest possible JSON object:

{
  "name": "Alice",
  "age": 30,
  "city": "London"
}

You can probably read that without any training. That readability is one of JSON's greatest strengths.

JSON Data Types

JSON supports exactly six data types. Understanding them is the foundation of working with JSON.

1. String

A sequence of Unicode characters enclosed in double quotes. Single quotes are not allowed in JSON.

"Hello, world!"
"user@example.com"
"2026-03-05"

2. Number

An integer or floating-point number. JSON does not distinguish between integer and float — both are simply "number". There is no separate type for dates, hex values, or infinity.

42
3.14159
-7
1.5e10

3. Boolean

Either true or false, written in lowercase. These are not strings — they have no quotes.

true
false

4. Null

Represents the intentional absence of a value. Written as lowercase null with no quotes.

null

5. Array

An ordered list of values enclosed in square brackets, separated by commas. An array can contain any mix of data types, including other arrays or objects.

["apple", "banana", "cherry"]
[1, 2, 3, 4, 5]
[true, null, 42, "mixed"]

6. Object

An unordered collection of key-value pairs enclosed in curly braces. Keys must be strings (in double quotes). Values can be any JSON type. Objects can be nested inside other objects or arrays.

{
  "id": 1,
  "active": true,
  "tags": ["admin", "user"],
  "address": {
    "street": "10 Downing St",
    "country": "UK"
  }
}

JSON Syntax Rules

JSON has a small, strict set of syntax rules. These are the most common rules beginners get wrong:

Here is a valid and invalid comparison:

// INVALID JSON (common mistakes)
{
  name: "Alice",          // key not in quotes
  'city': 'London',       // single quotes
  age: 30,                // trailing comma after last item
  active: True            // capital T
}

// VALID JSON
{
  "name": "Alice",
  "city": "London",
  "age": 30,
  "active": true
}

JSON vs XML vs YAML

JSON is not the only data format — but it is the most popular for web APIs. Here is how it compares to the other major formats:

Feature JSON XML YAML
Human readableGoodVerboseExcellent
CommentsNoYesYes
File sizeCompactLargeCompact
Native browser supportYesYesNo
Best forAPIs, dataDocumentsConfig files

For a deeper comparison between JSON and YAML specifically, see our JSON vs YAML guide.

Where JSON is Used

JSON is everywhere in modern software development. Here are the most common places you will encounter it:

Web APIs (REST APIs)

When your browser or app requests data from a server — whether loading your Twitter feed, checking the weather, or submitting a payment — the server almost always responds with JSON. It is the default format for REST APIs. The request body is JSON, and the response body is JSON.

Configuration Files

package.json in Node.js projects, tsconfig.json for TypeScript, manifest.json for browser extensions, appsettings.json in .NET — JSON is the dominant format for application configuration files.

Databases

Modern databases support storing and querying JSON directly. PostgreSQL has a native jsonb column type. MySQL has JSON columns. MongoDB stores documents as BSON (Binary JSON). Firebase and Firestore are built entirely around JSON-style documents.

Data Exchange Between Services

Microservices communicate over HTTP or message queues, and the messages are almost always JSON. Event-driven architectures (Kafka, SQS, Pub/Sub) publish and consume JSON events. Webhooks send JSON payloads to your endpoints.

LocalStorage and Browser APIs

Browser LocalStorage and SessionStorage only store strings. Developers use JSON.stringify() to serialize objects before storing and JSON.parse() to restore them. Service workers, IndexedDB, and the Web Storage API all work closely with JSON.

How to Read JSON

Reading JSON is straightforward once you recognize the two container types — objects (curly braces) and arrays (square brackets). Here is a real-world example of a JSON API response:

{
  "status": "success",
  "user": {
    "id": 42,
    "name": "Alice Chen",
    "email": "alice@example.com",
    "roles": ["admin", "editor"],
    "preferences": {
      "theme": "dark",
      "notifications": true
    },
    "lastLogin": "2026-03-05T10:30:00Z"
  }
}

Reading this step by step:

To access a value in code, you navigate the path. In JavaScript: data.user.preferences.theme gives you "dark". In Python: data["user"]["preferences"]["theme"].

Frequently Asked Questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. It was derived from JavaScript object syntax but is now a fully language-independent standard used in every major programming language. The official specification is IETF RFC 8259.

What are the data types supported by JSON?

JSON supports exactly six data types: string (text in double quotes), number (integer or decimal), boolean (true or false), null (no value), array (ordered list in square brackets), and object (key-value pairs in curly braces). There is no date type, no undefined, and no binary type in JSON.

Is JSON better than XML?

For most modern web API use cases, yes. JSON is more compact, easier to read, and natively supported by JavaScript. XML has advantages for document-oriented data, complex namespacing, and when an existing XML schema or toolchain already exists. However, for REST APIs and data exchange between web services, JSON is the overwhelming industry standard today.

How do I validate JSON?

Paste your JSON into the free validator at JSON Web Tools. The validator checks every syntax rule: quoted keys, correct comma placement, no trailing commas, valid value types, and properly nested brackets. It shows the exact line and character position of any error so you can fix it quickly.

Try the JSON Validator

Paste any JSON and validate it instantly. Free, private, no account needed.

Try JSON Validator →

Also useful: JWT Decoder | JSON Flatten Tool | JSON Key Sorter | Base64 JSON Tool | JSON vs YAML