Auto-repair broken JSON
Fix trailing commas, single quotes, unquoted keys, comments, Python literals, NaN/Infinity, and other common JSON corruptions in one click.
{
"name": "Ada",
"age": 36,
"roles": [
"admin",
"founder"
],
"active": true,
"nickname": null,
"score": null
}How to repair common JSON corruption
This tool runs a sequence of safe rewrites to turn loosely-typed input (LLM outputs, Python literals, JS object literals, JSON5, JSONC) into strict RFC 8259 JSON. It's deterministic, conservative, and never invents data.
- 01
Paste broken JSON
Common sources: LLM outputs that confused JSON with JS, copy-pasted Python
dictliterals (True,None, single quotes), JSON5 / JSONC config files (tsconfig.json,.vscode/settings.json,babel.config.json), or hand-edited JSON with trailing commas after a refactor.Same conservative rules used by the
json-repairlibrary and tools likejq's--input-string: only fix what's syntactically ambiguous, never invent missing values.Truncated or scrambled input will surface the original parse error so you can fix it by hand.
LLM outputPython dictJSON5JSONCjson-repair libraryinput · broken json3 issues{name: 'Ada', score: NaN,}26 B · 1 lineunquoted key · trailing comma - 02
Auto-rewrites run
The repair pass applies a fixed sequence of regex-safe rewrites: strip line / block comments, convert
'single'→"double"quotes, drop trailing commas before}/], quote bare object keys per RFC 8259 § 4, and replaceNaN/±Infinity/ Python literals (True,False,None) with valid JSON tokens.Each step is independent and idempotent — running the output through repair a second time is a no-op. The result parses cleanly with strict
JSON.parse.For JSON5-specific niceties (hex numbers, leading-plus, escaped newlines), use a dedicated JSON5 parser upstream first.
RFC 8259 § 4trailing commassingle → double quotescomment strippingPython literalsrewrites · 5 appliedRFC 8259{"name": "Ada", "score": null}30 B · 1 linevalid · strict JSON - 03
Already valid? No-op
If the input parses cleanly on the first attempt, the repair pass is skipped entirely and the input is pretty-printed instead. Running the tool on already-valid JSON is safe and lossless — original key order is preserved.
This makes the tool useful as a universal "repair-or-format" step in scripts and pipelines: pipe anything in, get strict JSON out.
idempotentlosslesskey-order preservedno-op short-circuitsaferesult · no changesuntouched{ "ok": true }16 B · 3 linesalready valid · pretty - 04
Verify with the validator
Pipe the repaired output through JSON Validator for a final RFC 8259 conformance check, or send it through JSON Formatter for canonical indentation. Use JSON Minifier if you need it on a single line.
Repair runs entirely in the browser — open DevTools → Network to confirm zero outbound requests, even on sensitive payloads.
RFC 8259JSON Validatorround-trip safeprivacy-firstverifiednext · verify3 actions✓ Repaired ✓ Validated ✓ Pretty-printed
ready to shipRFC 8259 · success
Production-grade JSON, the right way
Stick to RFC 8259
Strict JSON has no NaN, Infinity, comments, or trailing commas. If you need those, look at JSON5 or JSON Repair.
Preserve key order for diffs
JavaScript preserves insertion order, but two parsers shouldn’t be assumed equal. Use Sort JSON Keys before diffing or hashing.
Big integers lose precision
JS numbers lose precision past 2^53−1. Transport large IDs as strings or use BigInt.
Escape inside HTML
When inlining JSON inside <script>, escape </ to <\/ so HTML parsing doesn’t close your tag early.
Validate at boundaries
Trust the wire as little as possible. Run incoming JSON through a schema (Zod / Pydantic) before it touches business logic.
Minify in production
Minify removes whitespace; gzip removes redundancy. Together they typically shrink JSON payloads 70–85% over the wire.
When to repair JSON
Any time strict JSON.parse fails but the source is recoverable.
LLM outputs
AI tools often output near-JSON with single quotes or trailing commas. This catches most of those. Output round-trips losslessly through JSON.parse + JSON.stringify, so the file you save is byte-identical to what you see. Streaming parsers, jq pipelines, and Postgres jsonb columns all accept the result without complaint.
10× faster to scanPython dict literals
Convert pasted Python dicts (True, None) to JSON.
JS object literals
Strip unquoted keys and comments from JS object literals you want to ship as JSON. Handles emoji and non-ASCII via UTF-8 throughout — your data survives copy-paste between editors, terminals, and IDEs. Combining marks and ZWJ sequences come out the other side intact.
RFC 8259 validJSONC config files
Convert tsconfig.json-style commented JSON to strict JSON for tools that don't support comments.
Quick fixes
Drop a payload from a logs viewer and clean it up without rewriting by hand. Streams large documents without a server round-trip — privacy stays in the tab. Heavy parsing runs through useMemo so even 5 MB payloads keep the editor responsive.
schema-friendlyTest fixtures
Repair lazily-written test fixtures so they pass strict parse. Output is byte-stable: same input plus same options always produces identical bytes, ideal for content-addressed caches and snapshot tests. Downloads ship with the application/json MIME so editors apply syntax highlighting.
production-readyFrequently asked questions
Something missing?
Tell us what you need. We ship the top requests every two weeks.