What Is JSON? A Beginner's Guide with Examples
JSON explained for beginners: syntax rules, data types, real examples from APIs and config files, the most common errors and how to fix them.
JSON is everywhere: in the responses of almost every web API, in configuration files, in browser storage and in data exports. Even if you never write code, you will meet JSON sooner or later. The good news is that it takes about ten minutes to understand.
What JSON is
JSON (JavaScript Object Notation) is a text format for structured data. It was popularised by Douglas Crockford in the early 2000s as a lighter alternative to XML and is now an internet standard (RFC 8259). Despite the name, it is not tied to JavaScript: every programming language can read and write it.
Here is a small example:
{
"name": "Anna Schmidt",
"age": 34,
"member": true,
"tags": ["design", "photography"],
"address": {
"city": "Berlin",
"zip": "10115"
},
"phone": null
}
The building blocks
- Objects in curly braces
{ }: a set of key and value pairs. Keys are always strings in double quotes. - Arrays in square brackets
[ ]: an ordered list of values. - Strings in double quotes:
"Berlin". - Numbers without quotes:
34,-2.5,1e6. - Booleans:
trueorfalse, lowercase. - null: an empty value.
That is the whole language. Everything else is combinations of these six things, nested as deep as needed.
The strict rules that trip people up
JSON is deliberately strict, and most errors come from habits carried over from JavaScript or Python:
- Double quotes only.
'name'is invalid; it must be"name". - No trailing commas.
[1, 2, 3,]is invalid. - Keys must be quoted.
{name: "x"}is JavaScript, not JSON. - No comments. Neither
//nor/* */are allowed. - No special values such as
undefined,NaNorInfinity. - Escaping. Quotes and backslashes inside strings must be escaped:
"He said \"hi\"".
When something does not parse, paste it into a JSON validator. It points to the line and column of the first error, which is usually one of the cases above.
Where you will see JSON
APIs
When an app shows the weather or your bank balance, it usually asks a server for data and receives JSON. Developers inspect these responses constantly, and a formatter turns the single long line the server sends into a readable tree.
Configuration files
package.json in JavaScript projects, settings files in editors like VS Code, and many tool configurations use JSON. Some tools accept relaxed variants with comments, called JSONC or JSON5, but standard parsers will reject those.
Data exports
Many services let you download your data as JSON. It handles nested structures better than CSV: a customer with several addresses is natural in JSON and awkward in a spreadsheet.
Two details worth knowing
Dates have no special type in JSON. They are usually strings in ISO 8601 format ("2026-10-12T08:30:00Z") or numbers holding Unix timestamps. If you see a number like 1760258400, the timestamp converter shows the date.
Large numbers can lose precision. JavaScript represents numbers as 64-bit floating point and stays exact only up to 253, about 9 quadrillion. APIs with very large IDs, such as some social networks, send them as strings for this reason.
JSON vs other formats
- JSON vs XML: JSON is shorter and maps directly to data structures in code; XML is more verbose but supports attributes, namespaces and schemas, and remains common in enterprise systems and documents.
- JSON vs YAML: YAML is easier for humans to edit and allows comments, which is why it is popular for configuration; JSON is simpler and less ambiguous for machines.
- JSON vs CSV: CSV is perfect for flat tables; JSON for anything nested.
Our take
Learn to read JSON even if you never write code. It lets you understand exports, debug integrations and talk to developers in their language. Keep a formatter at hand, remember the three classic errors (single quotes, trailing commas, comments), and you will fix most broken JSON in seconds.