All posts

Developer Tools

JSON Debugging: 10 Tips That Save Hours

Faster ways to spot JSON syntax errors, inspect API payloads, and stop fighting with badly formatted webhooks.

March 30, 2026 · 7 min read

JSON looks simple — until it isn’t

Most developers can hand-write a JSON object. But the moment you’re looking at a 4 KB minified webhook payload from Stripe at 2 a.m., that comfort evaporates. Here are ten tips to stay sane.

1. Format before you read A formatted JSON document with consistent indentation is twice as fast to scan as a minified one. The FastDailyTools JSON Formatter does it instantly in your browser.

2. Validate before you parse If your code is throwing a vague `Unexpected token` error, paste the input into a validator first. The line and column number it gives you saves long debugging sessions.

3. Watch for trailing commas JSON does not allow trailing commas. JavaScript object literals do. This is the most common copy-paste-from-code error.

4. Quotes must be double quotes Single quotes work in JavaScript, not in JSON. `{"name": 'Alice'}` is invalid.

5. Keys must be strings `{1: "a"}` is invalid JSON. Use `{"1": "a"}`.

6. Watch out for trailing whitespace and BOMs A byte-order-mark or stray whitespace at the start of a file can break parsers. If a valid-looking file fails to parse, hex-dump the first few bytes.

7. Use jq on the command line For quick inspection of large API responses, `jq` is unbeatable. `curl ... | jq .` formats and `curl ... | jq '.items[0].name'` extracts.

8. Pretty-print with 2 spaces The community has converged on 2-space indentation. `JSON.stringify(obj, null, 2)` produces it.

9. Diff JSON, don’t diff strings When comparing two JSON documents, normalize both with the same formatter first, then diff. Otherwise key-order differences create noise.

10. Don’t store JSON when you mean a database This isn’t debugging advice, but: if you find yourself reaching for JSON files instead of a database, you’re building tomorrow’s pain. SQLite is free.