What Is JSON and What Is It For?

JSON is a common way to store data that's both readable by people and easy for programs to parse. Compared to XML it takes up less space, and its natural fit with JavaScript is what made it the web's default format.

Summary

JSON is a common way to store data that's both readable by people and easy for programs to parse. Compared to XML it takes up less space, and its natural fit with JavaScript is what made it the web's default format.

Step by step

  1. Learn the basic structure: curly braces represent an object, square brackets a list, and every value is tied to a key.
  2. Try a simple example, like writing a person's name, age, and hobbies as JSON.
  3. Run what you wrote through a validator to check it's valid; a missing comma or quote is the most common mistake.
  4. Look at a real API response, from your browser's developer tools, to see how JSON gets used in practice.

What data types does JSON have?

JSON has very few rules, and they all rest on a handful of types. A value can be a string in double quotes, a number, true or false, null for "no value", an object in curly braces, or an array in square brackets. Because objects and arrays can nest inside each other, that small set is enough to describe very complex data. A person might look like this: {"name": "Ayşe", "age": 29, "student": false, "hobbies": ["reading", "swimming"]}

Where you'll run into JSON

  • API responses, whenever a web or mobile app talks to its server.
  • Project config files, such as package.json in JavaScript projects.
  • Data exports, for example when a service lets you download your data.
  • Database fields set aside for records with a flexible structure.

Beginner mistakes

  • Putting numbers in quotes. "29" is a string, 29 is a number, and programs treat them differently.
  • Expecting a date type. JSON has none, so dates are usually stored as strings, often in a format like 2026-10-08.
  • Using spaces or special characters in key names. It's valid, but some languages make those keys awkward to access, so plain names are easier.
  • Repeating a key in the same object. Many parsers silently keep one, and it's not obvious which.

JSON or CSV?

For a flat table where every row has the same columns, CSV is simpler and opens straight into a spreadsheet. When the data is nested, say each customer has several addresses or orders, JSON carries that without forcing it into rows and columns. The shape of your data should decide.

A worked scenario

A student is building a small reading-list app for class. At first he stores each book as one line of text and struggles to pull out the author's name. After switching to JSON, each book becomes an object with title, author, year and a read flag, and the books sit in an array. Now a filter like "show unread books" means checking one field, not chopping up strings.