JSON is the format that nearly every modern app uses to send data over the internet. If you can write a list and a dictionary, you can write JSON. Here's everything you need to know in ten minutes.

What JSON is

JSON stands for JavaScript Object Notation. It's a text format for representing structured data — lists, key-value pairs, and nested combinations of both. A weather app's response, a tweet's metadata, a spreadsheet exported for an API: all of these are typically JSON.

A JSON document is a single value. That value can be one of six types: a string, a number, a boolean, null, an array, or an object. The last two — arrays and objects — can contain other values, which is what gives JSON its expressive power.

The six data types

Strings are text in double quotes:

"hello"
"Alice's order"
"line one\nline two"

Use double quotes, not single quotes. Special characters get escaped with a backslash: \n is a newline, \t is a tab, \" is a literal quote.

Numbers are written without quotes:

42
3.14
-7
1.5e10

JSON doesn't distinguish integers from floats — there's just one number type. No leading zeros (except 0 itself), no leading +, no trailing decimal point.

Booleans are true or false — lowercase, no quotes.

Null is the special value null, lowercase, no quotes. It means "no value".

Arrays are ordered lists in square brackets:

["apple", "banana", "cherry"]
[1, 2, 3]
[true, false, null]
[]

Elements are separated by commas. The last element does not get a trailing comma. Arrays can mix types (though most APIs keep them homogeneous).

Objects are key-value pairs in curly braces:

{
  "name": "Alice",
  "age": 30,
  "active": true
}

Keys must be strings in double quotes. Values can be any JSON type. Pairs are separated by commas. Again, no trailing comma after the last pair.

Nesting

The real power of JSON is that arrays and objects can contain other arrays and objects. This is how you represent complex data:

{
  "name": "Alice",
  "address": {
    "street": "123 Main St",
    "city": "Springfield",
    "zip": "12345"
  },
  "phones": ["555-1234", "555-5678"],
  "active": true
}

Read it like English: there's a person object with a name, an address object inside it, a phones array, and an active flag.

Writing valid JSON

The rules are strict. To write valid JSON, follow these:

  1. Strings always use double quotes, never single.
  2. Object keys are always strings — quote them.
  3. No trailing commas. The last item in an array or object has no comma after it.
  4. No comments. JSON is data, not source code.
  5. Numbers, booleans, and null have no quotes. "42" is a string; 42 is a number. They're different.

When you're not sure if a document is valid, paste it into our validator — it'll tell you exactly where any error is.

Pretty-printing vs minified

JSON ignores whitespace outside of strings, so the same data can be written compactly:

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

Or spread out for readability:

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

Both are equally valid. The compact form is what gets sent over the wire (fewer bytes); the pretty-printed form is what you read while debugging. Our JSON formatter converts between the two with one click.

Your first real example

Here's the kind of JSON you'd see returned from a weather API:

{
  "location": "London",
  "current": {
    "temperature_c": 12,
    "conditions": "Cloudy",
    "humidity_pct": 78
  },
  "forecast": [
    { "day": "Mon", "high_c": 14, "low_c": 8 },
    { "day": "Tue", "high_c": 13, "low_c": 7 },
    { "day": "Wed", "high_c": 15, "low_c": 9 }
  ]
}

Even if you've never seen this before, you can read it: there's a location, the current conditions inside an object, and a forecast as an array of daily entries. That's all of JSON.

What to learn next

Once you're comfortable with JSON syntax, three follow-ups are worth your time. The complete guide to JSON data types covers edge cases — large numbers, Unicode, what null vs missing-key means. Why is my JSON invalid? covers the most common parsing errors. JSON in REST APIs shows how it's used in practice.

For hands-on practice, try writing a JSON document describing yourself — name, age, favorite foods (as an array), and a nested object for your address. Paste it into our validator when you're done.