Skip to content
NewKitApp

Search tools

Jump to any tool by name

June 2, 2026

JSON Debugging: How to Format, Validate, and Minify Without Losing Your Mind

A practical walkthrough of the JSON errors developers hit most often — trailing commas, single quotes, unquoted keys — and how to fix them fast.

JSON Debugging: How to Format, Validate, and Minify Without Losing Your Mind

If you work with APIs, config files, or any modern web stack, you touch JSON dozens of times a day — and sooner or later, you paste in something that looks fine but throws Unexpected token anyway. This guide covers the handful of mistakes that account for almost every JSON parsing error, and the fastest way to fix each one.

The four errors that cause 90% of JSON failures

1. Trailing commas. This is valid JavaScript:

{ "name": "Ada", "role": "engineer", }

This is not valid JSON. The comma after "engineer" has nothing left to separate, and a strict JSON parser will reject it. This trips people up constantly because most JavaScript linters don't warn about trailing commas in object literals, so code that works fine as a JS object fails the moment you copy it into a .json file or a JSON.parse() call.

2. Single-quoted strings. JSON requires double quotes, full stop. {'name': 'Ada'} is invalid — it has to be {"name": "Ada"}. This one usually comes from developers hand-writing JSON while thinking in Python or JavaScript, where single quotes are perfectly normal.

3. Unquoted keys. In a JavaScript object literal, {name: "Ada"} is fine. In JSON, every key must be a double-quoted string: {"name": "Ada"}. Same root cause as #2 — JSON looks almost identical to a JS object literal, but the two have different rules.

4. Mixing up JSON with JSON5 or JSONC. Some tools (like VS Code's settings.json) accept comments and trailing commas because they use a more lenient JSONC parser under the hood. If you copy content out of one of those files expecting it to be strict JSON elsewhere, it'll fail.

Try it: JSON Formatter

Format, validate, and minify JSON instantly in your browser — no upload, no signup.

A faster debugging loop

Rather than scanning by eye for a stray comma, paste the JSON into a formatter that reports the exact line and column where parsing failed. That turns a multi-minute manual scan into a five-second fix — the JSON Formatter above does exactly this, and runs entirely in your browser so you're not pasting internal API responses into a random server.

Once your JSON is valid, the same tool doubles as a minifier (for shipping the smallest possible payload) and a pretty-printer (for reviewing a response in a PR or a bug report) — so you rarely need three separate tools for what's really one workflow: format, validate, minify.

When JSON isn't actually the right format

If you find yourself wanting comments in your JSON, or you're hand-editing large config files often, that's usually a sign YAML (or JSONC, if your tooling supports it) would serve you better — JSON's strictness is a feature for machine-to-machine communication, not for humans hand-editing config by hand. But for API payloads, package.json, and anything a program writes and another program reads, standards-compliant JSON remains the right default.