What you'll learn
- The only 2 containers in JSON
- The 6 allowed value types
- Why APIs send it minified
Open any API response, config file, or browser dev tools network tab, and you'll run into JSON — a wall of curly braces, colons, and nested brackets. It looks more complicated than it is. Once you know the handful of rules it's built on, reading (or writing) it stops being intimidating.
The only two containers
JSON has exactly two ways to group data:
- Objects
{ }— unordered key-value pairs, like{"name": "Alex", "age": 30}. Think of it as a labeled box: each key is the label, each value is what's inside. - Arrays
[ ]— ordered lists of values, like["red", "green", "blue"]. Order matters here, unlike in objects.
Everything else in JSON is just these two containers nested inside each other, however deep you need.
The only value types allowed
Unlike a programming language, JSON only permits six kinds of values: strings (always in double quotes, never single), numbers, booleans (true/false), null, and the two containers above. There's no date type, no way to add comments, and no trailing commas allowed after the last item in a list — three things that trip up almost everyone writing JSON by hand for the first time.
Common gotcha: {"a": 1, "b": 2,} — that trailing comma after the last value looks harmless but is invalid JSON. It's one of the most frequent reasons a "simple" JSON snippet suddenly fails to parse.
Why it took over from XML
JSON won out as the standard format for APIs mainly because it maps directly onto how most programming languages already represent data in memory — an "object" in JSON becomes an object or dictionary in your code with almost no translation needed. XML, the format JSON largely replaced, needed a parser to interpret tags and attributes into that same structure. Less translation means less code, fewer bugs, and faster parsing — which matters when an API might be sending thousands of responses a second.
Why minified JSON is unreadable — and why that's intentional
APIs almost always send JSON minified — no line breaks, no indentation, every unnecessary space stripped out. It's unreadable to a human, but every character removed is a character not being transmitted over the network, which adds up fast at scale. That's also exactly why formatter tools exist: to take that compressed wall of text and re-indent it back into something a person can actually scan.
Working with it
Paste any JSON blob into the JSON Formatter to re-indent it into readable form and catch syntax errors (a missing comma or an extra bracket is the single most common reason JSON fails to parse). For the reverse job — stripping whitespace and comments back out of code before shipping it — the Code Minifier / Beautifier handles JS, CSS, and HTML.
Tools mentioned in this post
0 comments
Leave a comment
More from the blog
Why Two Internet Speed Tests Never Agree
Run two speed tests back to back and you'll often get two different numbers — and neither...
Robots.txt vs. Sitemap.xml: Two Files With Completely Different Jobs
People often assume these two files do roughly the same thing for SEO. They don't — one te...
Why Designers Still Use 2,000-Year-Old Latin as Placeholder Text
Lorem ipsum isn't random gibberish — it's a scrambled passage from a real Roman philosophy...