What is JSON?

JSON (JavaScript Object Notation) is a way to write structured data as text. It looks like this:

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

Curly braces {} hold an object — a collection of key-value pairs. Here, name is a key and "Alice" is its value.

Square brackets [] hold an array — a list of objects:

[
  { "name": "Alice", "age": 30 },
  { "name": "Bob", "age": 25 }
]

JSON values can be strings, numbers, booleans, null, objects, or arrays:

{
  "name": "Alice",
  "age": 30,
  "active": true,
  "nickname": null,
  "address": { "city": "Tokyo" },
  "hobbies": ["reading", "hiking"]
}

Keys must always be in double quotes, and trailing commas are not allowed. If the format is wrong, code that tries to read it will break.

Where you'll see JSON

JSON is everywhere:

  • APIs — when your app talks to a server, the response is almost always JSON
  • Config filespackage.json, tsconfig.json, and many others are JSON
  • Databases — some columns store JSON directly for flexible, nested data

Why JSON?

Before JSON, data was exchanged in formats like XML, which looked like this:

<person>
  <name>Alice</name>
  <age>30</age>
</person>

JSON says the same thing in fewer characters, and JavaScript understands it out of the box. That made it the default choice for web APIs, and it stuck.