What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data format used to store and exchange structured data. It is the universal language of web APIs — when your app talks to a server, the response almost always comes back as JSON.

Human-readable
Language-independent
Used by 99% of REST APIs
Based on JavaScript syntax
RFC 8259 standard

JSON Syntax Rules

JSON has a simple, strict syntax with only a handful of rules:

  • Data is written as key/value pairs"key": "value"
  • Keys must be double-quoted strings — single quotes are not valid
  • Values can be string, number, boolean, null, object, or array
  • Objects are wrapped in {}, arrays in []
  • Items are separated by commas — no trailing comma after the last item
  • No comments allowed (use JSONC if you need comments)

JSON Data Types

String
"Hello, World!"Text wrapped in double quotes. Supports escape sequences like \n, \t, \".
Number
42 or 3.14 or -7Integer or floating-point. No quotes. Does not support Infinity or NaN.
Boolean
true or falseLowercase only. "True" or "False" are invalid JSON.
Null
nullRepresents an empty or unknown value. Lowercase only.
Object
{ "key": "value" }An unordered collection of key/value pairs wrapped in curly braces.
Array
[1, "two", true]An ordered list of values of any type, wrapped in square brackets.

JSON Examples

A basic JSON object

{
  "name": "Alice Johnson",
  "age": 30,
  "isActive": true,
  "score": 98.5,
  "address": null,
  "tags": ["developer", "designer"],
  "contact": {
    "email": "alice@example.com",
    "phone": "+1-555-0100"
  }
}

A JSON array of objects

[
  { "id": 1, "product": "Laptop", "price": 999.99 },
  { "id": 2, "product": "Mouse",  "price": 29.99  },
  { "id": 3, "product": "Keyboard","price": 79.99 }
]

Deeply nested JSON

{
  "order": {
    "id": "ORD-2026-001",
    "customer": {
      "name": "Bob Smith",
      "tier": "premium"
    },
    "items": [
      { "sku": "LAP-001", "qty": 1, "price": 999.99 },
      { "sku": "MSE-042", "qty": 2, "price": 29.99 }
    ],
    "total": 1059.97,
    "shipped": false
  }
}

Common JSON Mistakes

Single quotes on keys/values
✗ Wrong
{ 'name': 'Alice' }
✓ Correct
{ "name": "Alice" }
Unquoted keys
✗ Wrong
{ name: "Alice" }
✓ Correct
{ "name": "Alice" }
Trailing comma
✗ Wrong
{ "tags": ["a", "b", ] }
✓ Correct
{ "tags": ["a", "b"] }
Python-style booleans
✗ Wrong
{ "active": True }
✓ Correct
{ "active": true }
Comments (not allowed in JSON)
✗ Wrong
// comment
{ "x": 1 }
✓ Correct
{ "x": 1 }
undefined (use null instead)
✗ Wrong
{ "val": undefined }
✓ Correct
{ "val": null }

Frequently Asked Questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. Despite the name, it is language-independent and used across Python, Go, Java, Ruby, and virtually every modern programming language.

What is JSON used for?

JSON is primarily used for transmitting data between a server and a web application (REST APIs), storing configuration files, and as a data interchange format between services.

What are the JSON data types?

JSON supports 6 data types: string, number, boolean (true/false), null, object (key-value pairs in {}), and array (ordered list in []).

Is JSON the same as JavaScript?

No. JSON is a data format inspired by JavaScript object syntax, but it is strictly a text format. Unlike JavaScript objects, JSON keys must be double-quoted strings, and it does not support functions, comments, or undefined values.