What JSON is
JSON is a lightweight, text-based format for structured data. It was derived from JavaScript but is now language-independent — Python, Ruby, Go, Java, and virtually every modern language can read and write it. When your weather app shows a forecast or a website loads comments without refreshing, JSON is almost certainly moving behind the scenes.
Its popularity comes from two traits: humans can read it (unlike binary formats) and machines parse it trivially (unlike ad-hoc text). A JSON document is just text you could email, which makes debugging refreshingly direct.
The six data types
- Objects — unordered key/value collections in curly braces:
{"name": "Ada"}. Keys must be double-quoted strings. - Arrays — ordered lists in square brackets:
["math", "code"]. Items can be any type, mixed freely. - Strings — double-quoted text:
"hello". Single quotes are not allowed. - Numbers — integers or decimals:
42,3.14,-0.5,1.2e10. No hex, no leading zeros, noNaNorInfinity. - Booleans —
trueorfalse(lowercase only). - null — an intentional empty value, lowercase.
Syntax rules that matter
JSON's strictness surprises beginners coming from JavaScript:
- Double quotes only for strings and keys —
{'a': 1}is invalid. - No trailing commas —
{"a": 1,}fails. This is the most common error beginners hit. - No comments — strip
//and/* */before parsing. - No functions or undefined — data only.
When something breaks, paste it into our JSON formatter — it reports the exact line and column of the problem. The most frequent culprits are catalogued in common JSON errors, fixed.
A complete example
{
"name": "Ada Lovelace",
"born": 1815,
"fields": ["mathematics", "computing"],
"active": true,
"mentor": null,
"address": {
"city": "London",
"country": "UK"
}
}
Notice the nesting: an object containing an array, a nested object, and every scalar type. Real-world payloads look exactly like this, just larger. Whitespace — spaces, tabs, newlines — is insignificant, so the same document could sit on one line (that is what minified JSON is) and parse identically.
JSON in the wild: APIs and config files
You will meet JSON in two places constantly. First, web APIs: when an app requests data, the server usually responds with JSON. Open your browser's developer tools, visit a data-driven site, and inspect the Network tab — you will see JSON payloads shaped exactly like the example above. Developers test APIs by reading these payloads, which is why being able to scan JSON quickly is a genuine career skill.
Second, configuration files: package.json (JavaScript projects), tsconfig.json (TypeScript), VS Code's settings.json, and countless app configs are JSON. Here the strictness bites beginners most — one trailing comma and the whole tool refuses to start, with an error pointing at the wrong line. The debugging loop is always the same: validate, read the line/column, fix, re-validate.
A practical exercise: copy a small config file into our JSON formatter, press Format, and study how indentation reveals the nesting. Then deliberately break it — add a trailing comma, swap quotes — and watch the error messages. Ten minutes of intentional breaking teaches more than an hour of reading about syntax. Once you are comfortable, try fetching a public API in your browser and inspecting the raw JSON response.
Reading JSON is now within reach; writing it well is the next skill. Practice by formatting and validating your own snippets, and compare JSON vs. XML to understand why JSON won.