How to Fix Invalid JSON (Auto-Repair in Browser)
Updated 2026-06-21
To fix invalid JSON, paste it into a tool that auto-repairs the common syntax errors — trailing commas, single quotes, unquoted keys, comments and missing brackets — then re-serializes it as clean, parseable JSON. The JSON Sanitizer & Transformer does exactly this in your browser, with nothing uploaded to a server.
Why your JSON won't parse
Strict JSON is pickier than the relaxed object syntax most of us write by hand. The errors that break a parser are almost always one of these:
- Trailing commas — a comma after the last item in an object or array. Legal in JavaScript, illegal in JSON.
- Single quotes — JSON requires double quotes around every string and key. Pasted Python dicts and JS objects fail here.
- Unquoted keys — keys must be quoted strings, so an object copied from JS source needs every key wrapped.
- Comments — neither line nor block comments are valid in standard JSON.
- Missing or mismatched brackets — a dropped closing brace or bracket from a truncated copy-paste.
Knowing the category tells you what to look for, but you don't have to hand-edit each one.
Fix it in three steps
- Open the JSON Sanitizer & Transformer and paste your broken JSON into the input.
- Let it auto-repair: trailing commas are dropped, single quotes are converted to double, unquoted keys are wrapped, and comments are stripped.
- Copy the cleaned, re-indented output — now valid JSON that any parser will accept.
Worked example: paste an object like { name: 'Ada', roles: ['admin',], } and you get back the corrected version with double-quoted keys and strings, the trailing comma removed, and consistent indentation. What was a parse error becomes a clean two-key object.
Mask secrets before you share
Broken JSON often comes from a real API response or config file — which means it may carry API keys, tokens or passwords you do not want to paste into a ticket or chat. The sanitizer can mask secret-looking values so a field such as an api_key or password is redacted while the structure stays intact. Because everything runs locally in your browser, the original values never leave your machine in the first place — useful when the whole reason you're cleaning the file is to hand it to someone else.
Convert to YAML or CSV
Once your JSON is valid, you can transform it in the same panel:
- JSON to YAML for a config file or a CI pipeline that expects YAML.
- JSON to CSV when your data is an array of flat objects and you need a spreadsheet — each object becomes a row, each key a column.
If a conversion fails, it's usually a shape mismatch: CSV export expects an array of objects, so a single nested object or deeply nested arrays won't flatten cleanly.
Stop hand-hunting for that one stray comma. Paste your file into the JSON Sanitizer & Transformer, repair it in one click, and mask or convert it before you share — privately, in your browser.