Understanding JSON: A Practical Guide
Developer Tools - 6 min read - Published 2026-08-27
JSON (JavaScript Object Notation) is the format almost every web API speaks today, even in languages that have nothing to do with JavaScript. It won out over XML for a simple reason: it maps directly onto the data structures programmers already use - objects, arrays, strings, numbers, booleans, and null - with far less punctuation overhead.
The Rules Are Stricter Than They Look
JSON looks like a JavaScript object literal, which is exactly why people get tripped up by it. It isn't one. JSON has its own, stricter grammar: every key must be a double-quoted string (single quotes aren't allowed), trailing commas after the last item in an array or object are forbidden, and comments don't exist at all - there's no // or /* */ syntax in valid JSON.
Numbers can't have leading zeros (01 is invalid), and you can't write a bare NaN, Infinity, or undefined - JSON has no representation for any of them. If a value is genuinely absent, the convention is to use null.
Why Validators Give Confusing Errors
A JSON parser reads left to right and stops at the first character that breaks the grammar. That means the error position it reports is often just where the parser gave up, not necessarily where you made the actual mistake - a missing closing brace three lines earlier can surface as an error much later in the file. When a validator points at a location that looks fine, check upward from there first: unclosed strings, missing commas, and unmatched brackets are the usual culprits.
Nesting and Readability
JSON has no built-in limit on how deeply objects and arrays can nest, but deeply nested structures get hard to read fast. A formatter that indents consistently makes it much easier to visually track which closing bracket belongs to which opening one - especially useful when you're debugging an API response that arrived as one long unbroken line.
In Practice
If you're working with API responses, config files, or exported data, you'll run into malformed JSON eventually - a trailing comma left over from editing, a stray comment copied from JavaScript, or an unescaped quote inside a string. A formatter that both prettifies valid JSON and points out exactly where invalid JSON breaks is the fastest way to find the problem without manually counting brackets.