What Is JSON? A Beginner's Formatting Guide
JSON shows up everywhere in modern software — API responses, configuration files, app settings — yet a lot of people who work with it daily have never actually learned its rules formally. They copy an example, tweak it, and hope. That mostly works, until a single missing comma breaks an entire config file at 2am. Here's what JSON actually is, and how to avoid the mistakes that trip people up most.
JSON in one paragraph
JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data — objects, arrays, strings, numbers, booleans, and null. It was derived from JavaScript's object syntax but is now language-independent, and nearly every programming language has a library to read and write it. Its entire appeal is that it's both human-readable and easy for machines to parse.
The building blocks
JSON has exactly six data types, and understanding them prevents most formatting mistakes:
| Type | Example | Notes |
|---|---|---|
| Object | {"key": "value"} | Curly braces, key-value pairs, keys must be strings in double quotes |
| Array | [1, 2, 3] | Square brackets, ordered list of any JSON values |
| String | "hello" | Must use double quotes — single quotes are invalid JSON |
| Number | 42 or 3.14 | No quotes; supports integers and decimals |
| Boolean | true / false | Lowercase only, no quotes |
| Null | null | Represents an intentionally empty value |
The five mistakes that break almost every invalid JSON file
- Trailing commas.
{"a": 1, "b": 2,}is invalid — JSON does not allow a comma after the last item in an object or array, unlike JavaScript object literals. - Single quotes. JSON strings and keys must use double quotes;
{'a': 1}will fail to parse. - Unquoted keys.
{a: 1}is valid JavaScript but invalid JSON — keys always need double quotes. - Comments. JSON has no comment syntax at all;
// like thiswill break parsing immediately. - Missing or mismatched brackets. Every
{needs a matching}, and every[needs a matching]— easy to lose track of in deeply nested structures.
Why formatting (not just validating) matters
Minified JSON — everything on one line with no spacing — is efficient for machines but nearly unreadable for humans debugging an API response. A formatter re-indents nested objects and arrays consistently, making it obvious at a glance where one object ends and another begins. This is especially useful when debugging a deeply nested API payload, where a misplaced bracket six levels deep is nearly invisible in minified form but obvious once indented.
The reverse is also useful: once you've finished editing a JSON config file by hand, minifying it strips unnecessary whitespace before it's sent over a network or stored, saving bandwidth on high-traffic APIs.
A simple debugging workflow
When JSON won't parse, resist the urge to scan the whole thing manually. Instead, paste it into a JSON formatter — the error message will point to roughly where the syntax breaks, which narrows a search from "somewhere in 200 lines" to "around line 42." Fix that one issue, re-run it, and repeat; JSON errors are almost always singular and mechanical, not conceptual.
Frequently asked questions
No, standard JSON does not support comments of any kind. Some tools accept a relaxed variant called JSON5 or JSONC that allows comments, but that isn't valid standard JSON.
JSON is a stricter text format — it requires double-quoted keys and disallows trailing commas, functions, and comments — while a JavaScript object literal in code allows all of these.
It's safe with a formatter that processes everything locally in your browser using JavaScript's built-in JSON parser, since the data never leaves your device.
Conclusion
JSON's rules are stricter than they look at first glance, but they're also entirely mechanical — once you know the six data types and the five common mistakes, most "broken JSON" problems take seconds to spot. Keep a formatter bookmarked for the moments a config file refuses to parse.
Try it now with the JSON Formatter.