What was fixed

  • Paste some broken JSON to see what needs fixing.

Which repairs to apply

Enable all

About the JSON Repair Tool

What does JSON repair mean?

JSON is strict. Keys must be double-quoted, no comments are allowed, no trailing comma after the last item, and every bracket must close. Almost nothing that produces JSON in the real world respects all of that. JavaScript object literals use unquoted keys, Python prints True and None, language models wrap their output in markdown fences and stop mid-document, and config files pick up comments over time.

Repairing means turning that near-JSON into something a parser will accept, without changing what it says. This tool reads your input as a stream of tokens rather than running find and replace over it, which is what keeps the contents of your strings safe. A comma, a brace, or a // inside a string value is data, not syntax, and it is left exactly as written.

Most repair tools skip the part that matters most. This one shows you what it changed. Every repair is listed with a count, so you can see that it quoted six keys and removed two trailing commas rather than just handing back a block of JSON and hoping. You can also switch any individual repair off, which is how you find out precisely what was wrong in the first place.

What it fixes

  • Quoting: single-quoted strings, unquoted keys, bare words, and curly smart quotes pasted in from a document.
  • Commas: trailing commas before a closing bracket, and missing commas between items.
  • Comments: both // line comments and /* block */ comments.
  • Non-JSON literals: Python's True, False and None, plus NaN, Infinity and undefined.
  • Truncated output: unterminated strings and unclosed brackets, closed in the right order.
  • Wrappers: markdown code fences, JSONP callbacks, a leading byte order mark, and stray text after the document ends.
  • Invalid characters: raw line breaks and control characters inside strings, escaped properly.

How to Use This Tool

  1. Paste the broken JSON. Drop it into the left pane or use Open file. It repairs as you type.
  2. Read the report. "What was fixed" lists every repair with a count. If the badge stays red, the input needs a human, and the message says why.
  3. Narrow it down if you want to. Turn individual repairs off to see which problem was actually breaking your document.
  4. Take the result. Copy it, download it, or send it to another JSON tool with the buttons underneath.

Common Use Cases

  • Cleaning up model output: Language models routinely wrap JSON in fences, add commentary, or stop mid-object.
  • Pasted JavaScript objects: Copying an object literal out of source gives unquoted keys and single quotes.
  • Python dictionaries: A printed dict is very close to JSON, apart from the literals and quoting.
  • Truncated API responses: A cut-off log line can often be recovered well enough to read.
  • Config files with comments: Strip the comments to feed a strict parser.

Once it parses, the JSON Editor lets you edit it in a tree, the JSON Formatter beautifies it, and the JSON Validator checks it in detail. There are more in our free developer tools.

Frequently Asked Questions

Can repairing change what my data means?

The repairs are deliberately conservative, and string contents are never touched, so a comma or brace inside a value is safe. Two repairs do involve a judgment call, since closing a truncated document guesses where it should end, and quoting a bare word assumes it was meant to be text. Both are listed in the report so you can see they happened, and both can be switched off.

What if my JSON is already valid?

Then nothing happens to it. The badge says it was already valid, the report lists no fixes, and the output parses to exactly the same value. That is checked automatically against thousands of generated documents, because a repair tool that damages good input is worse than no repair tool.

Why is my JSON still invalid after repairing?

Because some damage cannot be guessed safely. If a document has lost a chunk from the middle, or the structure is ambiguous, there is no correct repair, so the tool says so and names the line rather than inventing something. Turning individual repairs off can help you narrow down where the real problem is.

Does it fix JSON from ChatGPT and other language models?

That is one of the cases it is built for. Markdown code fences, single quotes, Python style literals, trailing commas, and output that stops mid-object are all handled, which covers most of what models produce when asked for JSON.

Will it reformat my output?

By default it indents the result with two spaces. Set Output to "Keep as repaired" if you would rather see the minimal change, which is useful when comparing the before and after side by side.

Is my data uploaded anywhere?

No. The repair runs in your browser with JavaScript. Nothing is sent to a server, and the tool keeps working offline once the page has loaded.