Open the network tab on almost any website and you will see it: JSON, the text format that carries data between servers and browsers, stores app configuration, and glues services together. It is everywhere because it is simple — a handful of rules anyone can learn in ten minutes. This article covers those rules, the types, the gotchas, and why JSON won.
Use the JSON Formatter to tidy and inspect JSON, and the JSON Validator to catch errors — both run privately in your browser.
What JSON looks like
JSON represents data as key/value pairs grouped into objects, and ordered lists called arrays:
Read it top-down: an object (curly braces) holds keys, each pointing to a value. Values can be simple (a string, number, boolean) or themselves an array or object — which is how JSON represents deeply structured data.
The six data types
| Type | Example |
|---|---|
| String | "hello" — always double quotes |
| Number | 42, 3.14, -7 — no quotes |
| Boolean | true or false |
| Null | null — an explicit “no value” |
| Object | { "key": value } — unordered key/value pairs |
| Array | [1, 2, 3] — an ordered list |
That is the entire type system. Note what is missing: there is no date type (dates are stored as strings, usually in ISO-8601), and no way to store a function or a comment. The minimalism is deliberate.
The strict syntax rules
JSON’s reputation for being “fussy” comes down to a few non-negotiable rules — and breaking them is the cause of nearly every “invalid JSON” error:
- Double quotes only — both keys and string values. Single quotes are invalid.
- Keys must be quoted —
{name: "Ada"}is invalid;{"name": "Ada"}is correct. - No trailing commas — a comma after the last item breaks it.
- No comments — JSON has no comment syntax at all.
- No undefined — use
null;undefinedis not valid JSON.
JSON vs. JavaScript objects
JSON was derived from JavaScript’s object syntax, so they look nearly identical — but they are different things. A JavaScript object is a live structure in memory that can hold functions, use unquoted keys, and include trailing commas. JSON is text with the strict rules above. You move between them with two functions: JSON.parse() turns JSON text into a JavaScript object, and JSON.stringify() turns an object back into JSON text. Every language has its equivalent pair.
Why JSON won
Before JSON, data interchange meant XML — verbose, with opening and closing tags around every value. JSON carries the same data with a fraction of the characters, maps directly onto the data structures of every language (objects and arrays), and is trivially readable. It is the default for REST APIs, the payload format inside JWTs, the shape of most config files, and the storage format of document databases. Simplicity, ubiquity and human-readability made it the web’s data lingua franca.
In practice
JSON rewards a few minutes of care with rules that then never change. Keep the double-quote and no-trailing-comma rules front of mind, lean on a formatter to make nested data readable, and a validator to pinpoint errors. Try both with the JSON Formatter and Validator, and see how JSON fits the wider toolkit in Developer Data Essentials.
Frequently asked questions
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It represents data as key/value pairs and ordered lists, is readable by humans, and is supported by virtually every programming language — which is why APIs and config files use it.
What data types does JSON support?
Six: string, number, boolean (true/false), null, object (key/value pairs in curly braces), and array (an ordered list in square brackets). Objects and arrays can be nested to any depth. Notably, there is no date type — dates are stored as strings.
Why is my JSON invalid?
The usual culprits: a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, or a missing bracket/brace. JSON is strict — keys and strings must use double quotes, and no comments or trailing commas are allowed.
Is JSON the same as a JavaScript object?
They look alike but are not the same. JSON is text with strict rules (double-quoted keys, no functions, no comments, no trailing commas). A JavaScript object is a live in-memory structure that can hold functions and use relaxed syntax. You convert between them with JSON.parse and JSON.stringify.
How should I store a date in JSON?
JSON has no date type, so dates are stored as strings — and the best choice is the ISO 8601 format, like "2026-06-12T14:30:00Z". It is unambiguous, sorts correctly as text, and every language can parse it. Avoid locale formats like "06/12/2026", which are read differently around the world.
What is JSONL or NDJSON?
JSON Lines (also called NDJSON) is one JSON object per line, with no surrounding array. It is popular for logs and large datasets because a program can read and process it one record at a time without loading the whole file into memory — handy when the data is too big to fit at once.
How do I make large JSON readable?
Run it through a formatter (also called a "pretty printer"), which adds consistent indentation and line breaks so the nested structure is easy to follow. Minifying does the reverse — stripping all the whitespace to shrink the file for transport. The data is identical either way; only the spacing changes.