# JSON Repair - Fix Invalid JSON Online

Fix common JSON errors such as trailing commas, unquoted keys and single quotes. Review the suggested result in your browser before copying it: a repair cannot always know what you intended.

### Broken JSON

_{a:1,}_

Clear  Copy

If you meant to keep JSON5, use the [JSON5 validator](https://www.toolcomb.com/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](https://www.toolcomb.com/json-formatter) if you want a chosen indent, validate syntax on the [JSON validator](https://www.toolcomb.com/json-validator), or check a contract on the [JSON Schema validator](https://www.toolcomb.com/json-schema-validator). If the file is intentionally JSON5, do not “fix” comments away - keep the dialect on the [JSON5 validator](https://www.toolcomb.com/json5-validator).

The original and suggested result appear side by side, so you can check what changed. A repair may add quotes or remove a trailing comma, but it cannot recover missing information or reliably determine the intended meaning of a damaged document. Keep the original, check important values, and use the [JSON Schema validator](https://www.toolcomb.com/json-schema-validator) to check the repaired structure against your requirements. You can then compare valid versions with [JSON Compare](https://www.toolcomb.com/json-compare). The draft is saved in this browser on this device for up to 30 days. After you accept the object, query it on [JSONPath query](https://www.toolcomb.com/json-query) or diff it against a known-good fixture on [JSON compare](https://www.toolcomb.com/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** - The tool suggests a repair in your browser. The default example becomes {"a":1}, displayed with two-space indentation.
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 example has two mistakes: an unquoted key `a` and a trailing comma after `1`. The expected result is an object with one numeric field. Check the result and any error before copying it.

### 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)

Generated text and logs can be cut off before a JSON document ends. Repair may close open braces, but it cannot restore missing values. Treat a valid-looking result as incomplete until you compare it with the original source. Large drafts may also slow the browser.

### 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](https://www.toolcomb.com/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](https://www.toolcomb.com/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](https://www.toolcomb.com/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.

| Need | JSON repair (this page) | JSON formatter | JSON validator | JSON5 validator | JSON editor |
| --- | --- | --- | --- | --- | --- |
| Unquoted keys / trailing commas | ✓ heuristic | Rejects | Rejects | Valid JSON5 | Rejects |
| Pretty-print valid JSON | After parse | ✓ | No | No | Re-serializes |
| Keep comments on purpose | No - strips | No | No | ✓ dialect | No |
| Line/column of first syntax error | If still invalid | ✓ | ✓ | JSON5 errors | ✓ |
| Edit values in a tree | No | No | No | No | ✓ |
| Guarantee the output matches intent | No - read it | Yes if input parsed | N/A | N/A | You type it |

NDJSON, JSON Lines, and concatenated values are not this tool. Split them. Huge already-valid files belong on the [JSON file processor](https://www.toolcomb.com/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

Repair and validation run in your browser; the tool does not upload the draft for processing. Remember that browser extensions, shared screens and screenshots may still expose what you enter.

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. Repair runs in your browser. Your draft is saved in this browser on this device for up to 30 days and is not uploaded by the tool.

### Can this tool repair truncated JSON?

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 an error with a line and column when available. Simplify the draft or fix the remaining syntax by hand, then try again.

### 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. The tool is free and requires no registration. The size of a draft you can repair depends on your browser and device.

## 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:

- [JSON formatter](https://www.toolcomb.com/json-formatter) - pretty-print or minify after repair succeeds.
- [JSON validator](https://www.toolcomb.com/json-validator) - syntax-only RFC 8259 check without guessing quotes.
- [JSON5 validator](https://www.toolcomb.com/json5-validator) - keep comments and unquoted keys as a dialect.
- [JSON editor](https://www.toolcomb.com/json-editor) - edit the repaired object in text, tree, or table mode.
- [JSON compare](https://www.toolcomb.com/json-compare) - diff the repaired document against a known-good fixture.
- [JSON query](https://www.toolcomb.com/json-query) - run JSONPath once the document parses.
- [JSON Schema validator](https://www.toolcomb.com/json-schema-validator) - check types after the quotes are legal.
- [JSON file processor](https://www.toolcomb.com/json-file-processor) - large files that already parse, in a worker.

## Related Tools

Discover more free tools that might help with your next task.

[JSON Formatter Format and validate JSON data Use Tool](https://www.toolcomb.com/json-formatter)

[JSON Viewer View JSON data in a tree structure Use Tool](https://www.toolcomb.com/json-viewer)

[JSON Minifier Minify JSON data to reduce size Use Tool](https://www.toolcomb.com/json-minifier)

[JSON Editor Edit JSON in text, tree, and table modes. Works offline in the browser Use Tool](https://www.toolcomb.com/json-editor)

[JSON Query Query and transform JSON with JSONPath Use Tool](https://www.toolcomb.com/json-query)

[JSON Compare Diff two JSON documents path by path Use Tool](https://www.toolcomb.com/json-compare)

[View All Tools](https://www.toolcomb.com/tools)
