What Is JSON? A Complete Guide for Beginners With Real Examples
JSON is used in virtually every modern web application. This guide covers everything you need to understand it: what it is, how the syntax works, common errors, and where it appears in real projects.
JSON is one of the most widely used technologies in modern software, and one of the least explained clearly to people who are new to development. If you have seen JSON in a tutorial, a browser developer console, or an API response and wondered exactly what it is and how it works, this guide covers everything from first principles.
What Is JSON?
JSON stands for JavaScript Object Notation. It is a text-based format for storing and exchanging structured data. Despite the word "JavaScript" in the name, JSON is not a programming language and is not exclusive to JavaScript. It is used in Python, Java, PHP, Ruby, Go, C#, and virtually every other programming language.
JSON was invented by Douglas Crockford in the early 2000s as a simpler, lighter alternative to XML for web data exchange. Today it is the standard format for API communication, configuration files, and data storage in document databases.
JSON is not a programming language. It is a text format, a standardised way of writing structured data that any language can read and write.
Think of JSON as a universal language for data. When a mobile app needs to ask a server for your profile, the server sends the response back as JSON. When two different systems need to exchange information, JSON is the agreed format both sides write and read. It is the common currency of the modern web.
What Does JSON Look Like?
Here is a simple JSON object representing a person:
This JSON describes a person with five pieces of information. Each piece has a label, called a key, and an associated value. Keys are always wrapped in double quotes. Values have different types depending on what they represent. The whole thing is wrapped in curly braces, which means it is an object.
Now here is a more realistic example, the kind of JSON an API might return when you request a list of products:
This is an object at the top level. It contains a status string, a total number, and an array of product objects. Each product is itself an object with four fields. This nested structure, objects inside arrays inside objects, is how real-world JSON data is organised.
The Six JSON Data Types
JSON values must be one of exactly six types. There are no others. Every value you see in JSON, no matter how complex the document, is one of these six:
"Hello, world"
42 / 3.14 / -7
true / false
null
{ "key": "value" }
["a", "b", "c"]
JSON has no built-in date type. Dates are stored as strings, typically in ISO 8601 format (2026-03-15T08:00:00Z). How the receiving system parses that string depends on the application's code, not on JSON itself. This is a common source of confusion for beginners.
JSON Syntax — The Four Rules
JSON has exactly four syntax rules. Unlike programming languages, JSON has no flexibility. A single violation makes the entire document invalid and unparseable.
-
Keys must be strings in double quotes. Single quotes are not allowed. Unquoted keys are not allowed. This applies to every key in every object throughout the entire document.
-
Values must be one of the six types: string, number, boolean, null, object, or array. Nothing else is valid. No functions, no comments, no undefined, no Date objects.
-
Key-value pairs are separated by commas. The last pair has no trailing comma. A comma after the final item is one of the most common JSON errors.
-
Objects are wrapped in curly braces {} and arrays in square brackets []. Every opened bracket must be closed. Mismatched or missing brackets make the document invalid.
Here are all four rules applied correctly in a single document:
The 5 Most Common JSON Errors
These errors account for the vast majority of invalid JSON. Every one of them is easy to make and easy to fix once you know what to look for:
Instead of reading through every character manually, paste your JSON into the JSON Formatter. It validates the syntax instantly and tells you the exact line number where each error occurs. What would take 10 minutes by eye takes under a second.
Minified vs Formatted JSON
When JSON is transmitted over a network, it is often minified, with all whitespace, line breaks, and indentation removed to reduce the file size and speed up transfer. This is valid JSON, but it is very hard to read:
Both versions contain exactly the same data. Minified JSON is for machines, efficient to transmit and parse. Formatted JSON is for humans, easy to read and debug. When you receive a minified API response and need to understand what is in it, a JSON formatter converts it back to the readable version in one click.
Where JSON Is Used
JSON appears in virtually every part of modern software development. If you are building web applications, you will encounter it constantly across multiple different contexts:
GET /api/user/42 → { "id": 42, ... }
package.json, tsconfig.json
MongoDB, CouchDB, Firebase
Webhooks, message queues
What Is a JSON Formatter?
A JSON formatter is a tool that takes minified or messy JSON and restructures it with proper indentation and line breaks, making it readable. It also validates the syntax simultaneously, checking for errors and reporting the specific line where each error occurs.
When you are learning JSON, a formatter is invaluable. You can paste any JSON you encounter, from a tutorial, an API response, or a configuration file, and immediately see its structure clearly laid out. It is also the fastest way to find and fix syntax errors: the formatter highlights exactly where the problem is.
The StackDevTools JSON Formatter is free, runs entirely in your browser, and never sends your data to any server. Paste your JSON, click Format, and get a clean, readable, validated result immediately. If there is a syntax error, it tells you the line number so you can fix it directly.
Tools every JSON beginner should bookmark
Format and validate JSON, compare responses, and convert between formats. All free, all in your browser, no login required.
JSON Is Everywhere. Now You Understand It.
JSON is one of those technologies that appears immediately in real development work: in the first API response you ever inspect, in the first configuration file you open, in the first error message that references a malformed payload. Understanding it from first principles makes every one of those encounters less confusing.
The rules are small: double-quoted keys, six value types, commas between pairs, matching brackets. The errors are predictable: missing commas, trailing commas, single quotes, unclosed braces. And the tools to validate it are free and instant.
Start by pasting the next JSON you encounter into the formatter. Read the structure. Find the keys. Identify the value types. JSON becomes intuitive quickly, and once it does, you will find it everywhere.