Skip to content

Fix broken JSON, and see every change

JSON Mill repairs common JSON mistakes, including chatbot output, and lists every change so you can keep the fix or the original.

Repairs run on this device. Your JSON is never uploaded. How your data stays local.

Local
source
result

        
      
Loading the workspace...

JSON Mill's repair tool fixes the mistakes that make JSON invalid: trailing commas, comments, single quotes, unquoted keys, Python values such as True and None, Markdown code fences around chatbot output, and brackets left open when a file was cut off.

Before anything changes, it lists each fix with its line and column, grouped by kind, and you choose to apply them or cancel. Applying is one undo step. The repair runs in your browser.

How to fix broken JSON

  1. Paste the broken JSON. Paste it into the source panel or open the file. JSON Mill shows the first error and a Repair button.
  2. Press Repair. JSON Mill works out the fixes and shows them in the result panel: a count per kind of fix, then each change with its position, the old text and the new text.
  3. Review the changes. Click a change to jump to it in the source. Fixes that may change meaning, such as closing brackets at the end of a cut-off file or rewriting values like NaN and undefined, are highlighted.
  4. Apply or cancel. Press Apply repairs to make every change as one undoable step, or Cancel to keep your text as it was.

Example: JSON from a chatbot

A chatbot answer wrapped in a Markdown code fence, with single quotes, a Python True, a comment and two trailing commas.

Chatbot reply
```json
{
  'name': 'Trail Lantern',
  "price": 34.50,
  "in_stock": True,
  // added the tags field
  "tags": ["camping", "lighting",],
}
```
After Repair

{
  "name": "Trail Lantern",
  "price": 34.50,
  "in_stock": true,
  
  "tags": ["camping", "lighting"]
}

  • Changed values (for example True to true, NaN to null): 1
  • Fixed quotes: 1
  • Removed text around the JSON: 1
  • Other fixes: 1

The result is valid JSON with the same keys, values and number text; 34.50 keeps its trailing zero. Changes that sit next to each other are reported together, which is why the comment, the trailing commas and the closing fence show up as fewer items than the fixes they contain. The review panel lists each change with its line and column.

What JSON Mill can repair

  • Trailing commas after the last item, and missing commas between items.
  • Single quotes, curly quotes and unquoted keys.
  • // and /* */ comments.
  • Python and JavaScript values: True and False become true and false, None and undefined become null, and NaN and Infinity become the strings "NaN" and "Infinity".
  • Markdown code fences around the JSON: the three backticks, with or without json after them.
  • Truncated files: missing closing brackets and braces at the end are added, and JSON Mill warns that the file may be cut off.
  • JSON Lines files, one broken line at a time, so records are never merged into one array.

Options

Settings in the workspace that matter for this job
Option What it does
Repair Shown when the source is not valid JSON. Works out fixes without changing anything yet.
Apply repairs Applies every listed change to the source as one step. Undo brings the original back.

Limits

  • Text before or after a code fence, such as Here is the JSON you asked for:, is not removed reliably. Delete it before pressing Repair, or the result may wrap the text and the JSON together in an array.
  • Repair guesses at intent. Closing a cut-off file gives valid JSON, but any data after the cut is gone. Check highlighted fixes before applying.
  • If a document is too damaged to guess, JSON Mill says it could not repair it and changes nothing.

Questions

How do I fix JSON returned by ChatGPT or another LLM?
Paste the reply, delete any sentences before or after the JSON, and press Repair. JSON Mill removes the Markdown code fence and fixes the usual problems, such as single quotes, trailing commas, comments and Python True or None. Review the listed changes, then press Apply repairs.
Can it fix a truncated JSON file?
Partly. JSON Mill adds the closing brackets and braces that are missing at the end, so the file parses again, and it flags that the file may have been cut off. Anything that was cut off is not recovered, so check the end of the data.
Does repair change my numbers or strings?
Only where the fix requires it. Repair edits the spots it lists and leaves the rest of your text as it was, so number text such as 1.50, string escapes and key order stay the same. Values like NaN or True are rewritten to valid JSON and highlighted.
What is the difference between repair and validation?
The JSON validator tells you where the JSON breaks and why. Repair goes one step further and proposes the fix, with every change listed so you can accept or reject it.
Is my data uploaded?
No. JSON Mill processes your JSON in your browser, in a background worker on your device. Nothing leaves your device unless you choose to save or share a document, which needs an account, and JSON Mill tells you before it sends anything. How your data stays local explains how to check this yourself in your browser's developer tools.

Last updated