A JSON file is a plain-text container built from just two structural pieces — objects (curly braces) and arrays (square brackets) — filled with key-value pairs, and that is the whole anatomy. Everything else you see in a JSON file is one of six data types hanging off those two structures: strings, numbers, booleans, null, objects and arrays. Once you can name those parts, any JSON file, from a tiny settings file to a multi-megabyte data export, reads the same way.
The four parts every JSON file is made of
JSON stands for JavaScript Object Notation, and its grammar is deliberately small. A file has one root value, which is almost always an object or an array. Inside it, only four kinds of building block appear:
| Part | Written as | What it holds |
|---|---|---|
| Object | { } | An unordered set of key-value pairs; keys are always double-quoted strings |
| Array | [ ] | An ordered list of values, separated by commas; order is meaningful |
| Key | "name": | A label in double quotes, followed by a colon, then its value |
| Value | varies | A string, number, boolean, null, object or array |
Values come in exactly six types. A string is text in double quotes, like "active". A number is written bare, like 42 or -3.5, with no quotes and no units. A boolean is the bare word true or false. Null is the bare word null and means "no value here". The last two types are the object and the array, which can nest inside each other as deeply as the data requires. That nesting is the reason JSON scales: a single object can hold an array of objects, each of which holds more objects.
How the punctuation holds a JSON file together
JSON has strict punctuation rules, and most broken files fail on one of them. Keys and string values use double quotes only — single quotes are not valid JSON. Pairs inside an object are separated by commas, and the last pair must not have a trailing comma. Arrays follow the same comma rule. Colons separate a key from its value, with no space required but one space conventional. Whitespace — spaces, tabs, line breaks — is ignored entirely by the parser, which is why a minified JSON file can sit on one long line and still be valid. Indentation is a readability choice, not a syntax requirement; two spaces per level is the common convention.
A minimal but complete file looks like this:
Read it part by part: the outer braces are the root object. Inside, one key, "user", points to a nested object. That nested object holds four keys — a string, a number, a boolean, an array of two strings — plus a null. Nothing else is needed; that is a whole JSON file.
What a real JSON file looks like, layer by layer
Most files you meet are larger versions of that skeleton. Take an order record: the root object holds an "orderId" string, a "total" number of 129.5, a "paid" boolean of false, and a "items" array. Each element of the array is itself an object with "sku", "qty" and "price" keys. To read any JSON file, work top-down: find the outermost braces or brackets, identify each key at that level, then follow the value into the next level only when you need it.
Two habits make this fast. First, count the nesting depth by the brackets: every opening brace or bracket must have a matching closer, and the file is invalid if they do not balance. Second, remember that an array's order matters while an object's key order does not — parsers may return object keys in any order, so never rely on "name" appearing before "age". If you need order, put the data in an array.
Where JSON files go wrong and how to fix them
The failures are almost always punctuation, not content. A trailing comma after the last item, single quotes around a key, an unquoted key, a missing colon, or a value like NaN or undefined that JSON does not allow will each stop a parser cold. Comments are not permitted in JSON either, so a file with // notes will fail. Numbers cannot carry leading zeros or a leading plus sign, and strings cannot contain a raw line break — it must be escaped as \n.
When a file will not parse, check in this order: balance of braces and brackets, commas between every pair and none after the last, double quotes on every key and string, then the six allowed value types. A validator that reports the line and column of the first error saves time; fix that error, re-run, and repeat, because parsers usually stop at the first fault and hide the rest. Encoding is the other trap: JSON is defined as UTF-8, so a file saved in another encoding can produce unreadable characters even when the punctuation is perfect.
JSON versus the formats it replaced
Compared with XML, JSON uses less punctuation per value and maps directly onto the objects and arrays most programming languages already have, which is why it became the default for web APIs and config files. It has no schema of its own, so a JSON file is only as consistent as whoever wrote it; tools like JSON Schema exist to check structure separately. It also cannot represent dates, binary data or comments natively — dates travel as strings and binary as encoded text. Knowing that limit tells you what to expect: a JSON file is data, not a document, and it carries no instructions about how that data should be displayed or validated.