What Is JSON? A Beginner's Guide With Examples
Learn what JSON is, how its syntax works, the six data types it supports, and the most common errors that make JSON invalid โ with simple examples.
If you work with websites, apps or APIs, you will meet JSON almost every day. It is the format most web services use to send data back and forth. This guide explains JSON from scratch and shows the mistakes that most often break it.
What is JSON?
JSON stands for JavaScript Object Notation. It is a plain-text format for storing and sending structured data. Even though the name mentions JavaScript, almost every programming language โ Python, Java, PHP, Go and more โ can read and write JSON.
Here is a small example describing a user:
{ "name": "Asha", "age": 28, "isMember": true, "skills": ["Excel", "SQL"], "address": { "city": "Pune", "pin": "411001" } }
Even without any training you can probably read it: a user named Asha, aged 28, who is a member, has two skills and lives in Pune.
The building blocks
JSON is built from just two structures:
- Objects โ a set of keyโvalue pairs inside curly braces { }. Keys are always text in double quotes, followed by a colon and the value. Pairs are separated by commas.
- Arrays โ an ordered list of values inside square brackets [ ], separated by commas.
Objects and arrays can be placed inside each other to any depth, which is how JSON describes complex data.
The six data types
A JSON value can only be one of these:
- 1String โ text in double quotes, such as "Pune"
- 2Number โ such as 28 or 3.14 (no quotes, no leading zeros)
- 3Boolean โ true or false
- 4Null โ null, meaning "no value"
- 5Object โ { ... }
- 6Array โ [ ... ]
Dates, functions and comments are not part of JSON. Dates are usually sent as strings, for example "2026-11-19".
The most common JSON errors
Most "invalid JSON" errors come from a handful of mistakes:
- Single quotes. JSON needs double quotes: "name", not 'name'.
- Trailing commas. A comma after the last item, such as ["a", "b",], is not allowed.
- Unquoted keys. { name: "Asha" } is valid JavaScript but invalid JSON.
- Comments. // and / / are not allowed in JSON.
- Missing brackets. Every { needs a } and every [ needs a ].
- Special characters in strings. Quotes and backslashes inside a string must be escaped, for example \" and \\.
Formatting vs minifying
APIs often send JSON as one long line with no spaces. This is called minified JSON โ it is smaller to send but hard for people to read. Formatting (or "pretty-printing") adds line breaks and indentation so you can see the structure. Both versions contain exactly the same data.
JSON vs XML
Before JSON became popular, many systems used XML. JSON is usually shorter, easier to read and maps directly to the objects and lists used in code, which is why most modern web APIs use it.
Try it yourself
Paste any JSON into the JSON Formatter to pretty-print it, minify it or find the exact line where it is invalid. Everything runs in your browser, so API responses with private data stay on your computer.