Fundamentals

What Is JSON? The Only Beginner's Guide You Actually Need

8 min read

If you have ever opened a package.json file, copied an API response into a text editor, or saved user settings in a web app, you have already used JSON. You just might not have known what to call it.

JSON - short for JavaScript Object Notation - is the universal shipping container of the internet. It is not a programming language. You cannot build apps with it. But every app you use relies on it to move information from one place to another. It is boring, invisible, and absolutely essential.

A 30-Second History Lesson

JSON was specified by Douglas Crockford in the early 2000s. He didn't invent a new format - he discovered that a subset of JavaScript's object literal syntax already worked perfectly as a language-independent data interchange format. He formalized the rules, gave it a name, and published the spec at json.org in 2002.

Simplicity is why JSON won. The entire specification fits on a single page. There is almost nothing to argue about, almost nothing to implement incorrectly, and almost nothing to learn. It was later standardized as ECMA-404 and RFC 8259, but the spec barely changed - because there was barely anything to change.

What JSON Actually Looks Like

JSON is built on two structures: objects (key-value pairs wrapped in curly braces) and arrays(ordered lists wrapped in square brackets). That's it. Everything in JSON is one of these two containers, or a value inside them.

Objects

An object is a collection of key-value pairs. Keys must be strings in double quotes:

{
  "name": "Ada Lovelace",
  "born": 1815,
  "knownFor": "First computer programmer"
}

Arrays

An array is an ordered list of values:

{
  "languages": ["Python", "JavaScript", "Go", "Rust"]
}

The Six Value Types

JSON supports exactly six value types:

That's the complete list. There is no date type. No undefined. No comments. No functions. This constraint is intentional - it keeps the format simple, unambiguous, and parseable by every programming language on earth.

Where You Will Encounter JSON

REST APIs

This is the big one. The vast majority of web APIs send and receive JSON. When your frontend fetches data from a backend, JSON is almost certainly the format on the wire. Every major API - GitHub, Stripe, Twilio, OpenAI - returns JSON by default.

Configuration Files

package.json, tsconfig.json, .eslintrc.json - the JavaScript ecosystem and the broader developer world lean heavily on JSON for configuration. It is not always ideal for this purpose (the lack of comments is painful), but it has become the convention.

Databases

Document databases like MongoDB store data as JSON (technically BSON). PostgreSQL and MySQL both have native JSON column types, letting you store semi-structured data inside relational tables. JSON blurs the line between relational and document databases in useful ways.

Browser Storage

Browser localStorage only stores strings, so JSON.stringify() and JSON.parse()are the standard way to persist structured data on the client side. If you have ever saved a user's preferences or a shopping cart in the browser, you have used JSON serialization.

Common Mistakes That Trip Up Beginners

JSON is stricter than JavaScript. If you are coming from JS, these will trip you up:

// These are all INVALID JSON:

{ name: "test" }            // unquoted key
{ 'name': 'test' }          // single quotes
{ "name": "test", }         // trailing comma
{ "name": "test" /* */ }    // comment

Every key must be a double-quoted string. Every string value must use double quotes - not single quotes. Trailing commas after the last item in an object or array are not allowed. And you cannot include comments, even though every developer on earth wishes you could.

Why Formatting Matters

Raw JSON from an API or a minified file is typically one long line of text. Hundreds of characters of nested brackets, quotes, and commas, with no visual structure. It is nearly impossible to read.

A formatter adds indentation and line breaks so you can actually see the hierarchy. It transforms a wall of text into something you can scan in seconds. Try it yourself with our online JSON formatter - paste any JSON and see the difference instantly.

For a complete walkthrough of formatting methods, see our guide on how to format JSON. And if you are running into syntax errors, check out the most common JSON errors and how to fix them.

See JSON Formatting in Action

Now that you understand JSON, try pasting a real API response into our formatter and see how much easier it is to read.

Open JSON Prettifier