The JSON Debugging Checklist

Every common JSON failure, what actually causes it, and the fastest fix. Each recommended tool is 100% client-side — paste your payload, and nothing leaves your browser.

1 · Unexpected token <x> in JSON at position N

The error everyone hits first. The parser stopped at the first character it couldn't reconcile — the position is exact, but the cause is usually one line above or below it.

SymptomReal causeFix
Unexpected token } / ,]Trailing comma before } or ] — legal in JS object literals, illegal in JSONJSON validator with auto-repair fixes it in one click
Unexpected token 'Single-quoted keys or string values ({'a': 1})Same validator — it quotes them properly
Unexpected token /JavaScript-style // or /* */ commentsStrip them, or validate as JSONC with the JSONC validator
Unexpected token <You're parsing an HTML error page (500, login redirect, rate-limit page), not JSONLook at the first characters of the payload; log the raw response before parsing
Unexpected token  / error at position 0UTF-8 BOM or invisible whitespace copied from a PDF/webpageUnescape & clean the string, then re-validate
Chrome 114+ changed how V8 words JSON syntax errors, which silently broke a wave of tools that parsed V8's error strings. A scanner written against the JSON spec keeps reporting exact line/column regardless of browser updates — here's why that matters.

2 · Escaped JSON inside JSON

Logs, queues, and webhooks love to double-encode: a JSON string whose value is another JSON document full of \" and \n.

3 · "My JSON is valid but the API rejects it"

Syntactically valid ≠ what the endpoint expects. Contracts break in three ways: wrong types ("42" vs 42), missing required fields, and values that violate a format (date-time, email, uri).

4 · Extracting one value from a 4,000-line payload

5 · Comparing two payloads

"Why did the response change after the deploy?" Diff them structurally — key order shouldn't matter, so a text diff lies.

6 · Converting JSON to something else

TargetTool
CSV (rows/columns)JSON → CSV
TypeScript typesJSON → TypeScript
Python modelsJSON → Python
Java classesJSON → Java
Rust structsJSON → Rust
Go structsJSON → Go
C# classesJSON → C#
YAML / TOML / XML→ YAML · → TOML · → XML

7 · Shipping: size, ordering, and dialects

8 · Before you paste into any web tool

In November 2025, watchTowr Labs disclosed that CodeBeautify.org had been exposing user-pasted payloads — API keys, SSH keys, cloud credentials — through a public "Recent Links" feed. Most "online tools" still POST your data to a server. The 30-second audit: open DevTools → Network, clear, paste, hit format. Any request carrying your payload = it left your machine. Full breakdown: the CodeBeautify leak explained · what makes a JSON formatter actually secure.