JSON runs the modern web. Every API response, config file and log line is JSON. But minified JSON is unreadable, and one stray comma can break your whole pipeline. Here's how to work with it fast.
The rules browsers actually enforce
- Keys must be **double-quoted strings**. Single quotes are invalid.
- No **trailing commas** after the last item.
- No **comments** (`//` or `/* */`) — use JSON5 or JSONC if you need them.
- Numbers: no leading zeros, no `+`, no `NaN` or `Infinity`.
- Strings must escape `"`, `\`, and control characters.
The four things you'll do 90% of the time
1. **Pretty-print** minified JSON to read it.
2. **Minify** pretty JSON to ship it.
3. **Validate** to catch syntax errors before pushing.
4. **Diff** two payloads to spot what changed.
Do it now
Paste your payload into [JSON Formatter](/tools/json-formatter) — it validates, pretty-prints, and shows the exact line where a syntax error lives. For diffs, [Text Diff](/tools/text-diff) does the trick.
Debugging tips from years of API work
- If a response looks fine but your parser fails, check for an invisible **BOM** at the start.
- Duplicate keys are technically legal but only the last wins — most bugs live here.
- `null` vs missing key are different in most parsers. Design for both.
- Never log unredacted JSON to disk. Tokens leak this way.
When to reach for something else
JSON is text-only and verbose. For binary blobs use Base64 (see [Base64 Encoder](/tools/base64)). For high-throughput internal services, Protocol Buffers or MessagePack pay off. For human-edited config, YAML or TOML are easier on the eyes.