Skip to main content

JSON Repair - Turn Messy Drafts into RFC 8259 JSON

Default {a:1,} becomes {"a":1}. Heuristic repair in the browser. Read the output; it is not always what you meant.

Broken JSON

If you meant to keep JSON5, use the JSON5 validator instead of converting.

Repaired JSON

{
  "a": 1
}

What Is a JSON Repair Tool?

A JSON repair tool takes text that looks like JSON to a human - unquoted keys, trailing commas, single quotes, leftover comments - and tries to emit RFC 8259 JSON that JSON.parse will accept. Formatters refuse that input on purpose. Humans still type it because those mistakes are legal in JavaScript object literals and in JSON5. The default on this page is {a:1,}. Repair emits {"a":1}, which this page pretty-prints with two-space indent. That is the worked example. Single quotes, comments, concatenated objects, and Python True / None are in scope for many drafts. Truncated binary garbage is not a promise.

Repair is a heuristic, not a specification. Inserting a missing comma in the wrong place can join two values. Closing a truncated array can invent an empty tail. Always read the pretty result before you paste it into production. Then pretty-print on the JSON formatter if you want a chosen indent, validate syntax on the JSON validator, or check a contract on the JSON Schema validator. If the file is intentionally JSON5, do not “fix” comments away - keep the dialect on the JSON5 validator.

The algorithm is the jsonrepair library. This page makes repair the primary job: original versus repaired, with a parse check after the heuristic. Auto-fix on a viewer is easy to miss. Here the right panel is the whole product. Typical wins are quoting bare keys, dropping a trailing comma, rewriting single quotes, and mapping Python literals. Typical misses are a string cut in half, a function dumped from a console, or two documents concatenated without a delimiter you intended. Processing stays in the browser. The draft persists in localStorage for up to 30 days on this device. That is a scratch pad, not a recovery vault for a corrupted export. After you accept the object, query it on JSONPath query or diff it against a known-good fixture on JSON compare.

How to Repair Malformed JSON - Step by Step

Repair runs live as you type. Copy stays disabled until JSON.parse succeeds on the heuristic output.

  1. Paste the broken draft - Keep the default {a:1,} or paste unquoted keys, trailing commas, or other messy text into the left panel.
  2. Read the repaired JSON - jsonrepair runs in the browser. The expected default result is {"a":1}, which JSON.parse accepts, then pretty-printed with two-space indent.
  3. Confirm the heuristic is what you meant - Repair can insert commas or quotes in the wrong place. Read the output before you trust it.
  4. Copy the RFC 8259 result or restore the sample - Copy only after you agree with the interpretation. Clear restores {a:1,}. Nothing is uploaded.

JSON Repair Worked Example - Before and After

The default string is short on purpose so you can see both mistakes at once: a bare key a and a trailing comma after 1. If the right panel is not an object with a single numeric field, the library or the parse check failed.

Input - invalid draft

{a:1,}

Output - RFC 8259 JSON, pretty-printed

{
  "a": 1
}

Extra drills on the same page: {'a':1} should quote the key with double quotes. {a:1,b:2,} should drop the last comma. A line comment above an object is often stripped so the object can parse. A file cut in the middle of a string may still fail - that is an honest miss, not a spinner that pretends success.

When You Need JSON Repair - Real-World Use Cases

Salvaging a JavaScript object literal from a console.log

DevTools often prints objects with unquoted keys. Copying that dump into a formatter fails. Paste it here first. If the dump included functions or undefined, repair may still fail or drop those slots - read the output and do not treat a console object as a serialization format.

Fixing trailing commas from hand-edited config

People edit settings.json-shaped files as if they were JavaScript. The last property keeps a comma because the next line might arrive tomorrow. RFC 8259 forbids that comma. Repair removes it. If your toolchain actually wants JSONC (VS Code settings), comments will disappear here; use a JSONC-aware path instead of converting.

Converting single-quoted strings from mixed language dumps

Python repr, some logs, and copy-pasted snippets use single quotes. JSON does not. The heuristic often rewrites them to double quotes. Nested quotes inside strings are the usual footgun - confirm the pretty print still has the same characters you care about.

Closing truncated model or log output (with limits)

Language models and log shippers cut JSON at a byte limit. jsonrepair sometimes closes open braces. That can invent an incomplete object that parses but is missing the tail of the data. Use it to unblock a parser, then treat the result as damaged until you have the full payload. Do not load a 40 MB truncated log into this textarea.

Cleaning concatenated objects from log lines

Two objects stuck together {a:1}{b:2} are not one JSON value. Repair may wrap or join them. If you needed NDJSON, split on newlines yourself. This page is one document in, one document out.

Recovering a draft so a formatter will accept it

The JSON formatter must refuse invalid input or it would silently invent structure. Repair is the step before format. After you agree with the object, format or minify on that page. Keep the jobs separate so you can see what the heuristic changed.

Turning Python True / None dumps into JSON literals

Naive Python prints use True, False, and None. JSON wants lowercase true / false / null. Many drafts convert. Nested Python datetime objects will not. Prefer json.dumps at the source when you control the exporter.

Preparing a broken vendor export for schema validation

Vendor “JSON” is often JSON5-ish. Schema validators expect RFC 8259. Repair, read, then validate on the JSON Schema validator. If validation fails on types, that is a data problem, not a quote problem. Diff the repaired file against a known-good fixture on JSON compare.

Repair vs Formatter, JSON5, Validator, and Sibling Tools

Repair is the messy-input lane. The other tools assume you already know the dialect.

NeedJSON repair (this page)JSON formatterJSON validatorJSON5 validatorJSON editor
Unquoted keys / trailing commas✓ heuristicRejectsRejectsValid JSON5Rejects
Pretty-print valid JSONAfter parseNoNoRe-serializes
Keep comments on purposeNo - stripsNoNo✓ dialectNo
Line/column of first syntax errorIf still invalidJSON5 errors
Edit values in a treeNoNoNoNo
Guarantee the output matches intentNo - read itYes if input parsedN/AN/AYou type it

NDJSON, JSON Lines, and concatenated values are not this tool. Split them. Huge already-valid files belong on the JSON file processor, which will not try to guess quotes.

Common Repair Failures and Honest Limits

Heuristics fail in recognizable ways. Treat these as expected, not as bugs to hide.

  • Joined values. A missing comma between 1 and 2 might become the number 12. Read the pretty print.
  • Comments disappear. Strict JSON has no comments. If comments must survive, you wanted JSON5 or JSONC.
  • Truncated strings. A cut inside quotes may never close. The error after parse is the honest result.
  • NDJSON merged. Many values per file need a split step you do yourself.
  • Functions, dates, undefined. Those are JavaScript, not JSON. Repair cannot serialize a function.
  • Duplicate keys after parse. The later key wins. Repair will not resurrect the discarded one.
  • IEEE-754 ids. Huge integers may round once the text becomes a JavaScript number. Keep ids quoted if they must be exact.
  • Tab-sized logs. Repairing tens of megabytes in a textarea will hitch the UI. Cut a sample. Use the file processor only when the file already parses.

Privacy & Security - 100% Browser-Side Repair

jsonrepair and the follow-up JSON.parse run entirely in your browser. The draft is never posted to a repair API. That is appropriate for config snippets and captured logs - still avoid pasting live secrets into any web origin. Extensions, shared screens, and screenshots can see the textarea.

The broken text auto-saves to localStorage under a key unique to this tool for up to 30 days. It never leaves this device. Click Clear to restore {a:1,}. Clearing site data for this origin deletes the saved draft as well.

Frequently Asked Questions

What kinds of malformed JSON can be repaired?

Typical draft mistakes: unquoted keys, trailing commas, single quotes, comments, concatenated objects, and Python-style True/False/None in many cases. The default {a:1,} becomes {"a":1}.

Is repaired JSON always what I meant?

No. Repair is heuristic. A missing comma might join two values. Always read the pretty-printed output. Schema validation is a separate step on the JSON Schema validator.

Does JSON repair replace the JSON formatter?

No. The formatter pretty-prints valid JSON and must refuse invalid input. Repair exists because formatters cannot guess quotes and commas. Pretty-print after repair on the JSON formatter if you want a chosen indent.

Is my broken file uploaded?

No. jsonrepair runs entirely in the browser. The draft is stored in localStorage on this device for up to 30 days and is never sent to a server.

Can jsonrepair fix truncated files?

Sometimes it closes open brackets. A file cut in the middle of a string may still fail. Use the JSON file processor only for valid large files, not as a second repair pass.

When should I use JSON5 instead of repair?

JSON5 is a defined dialect that allows comments and unquoted keys on purpose. If you want to keep that dialect, validate it on the JSON5 validator instead of converting it to strict JSON.

What happens if JSON.parse still fails after repair?

The page shows the first parse error with a line and column, and may still display the heuristic text. That means the library could not produce RFC 8259 JSON. Simplify the draft or fix the remaining syntax by hand.

Does repair keep comments?

No. Strict JSON has no comments. Repair strips or rewrites comment-like text so JSON.parse can succeed. If comments must survive, you are writing JSON5 or JSONC, not JSON.

Can I repair NDJSON (one value per line)?

Not reliably. Newline-delimited JSON is many documents, not one. This tool may wrap or merge lines incorrectly. Split lines yourself, repair each value, then join them again.

Is this JSON repair tool free?

Yes. There is no registration, no repair quota, and no premium auto-fix. Run jsonrepair as often as you need on drafts that fit in the textarea.

Related JSON Tools

Repair is the messy-input step. These sibling tools take over once the text is strict JSON - or when you should not convert at all: