LAB QUOTA · OK
[ json-fix:// ] experimental
cat: code model: @cf/meta/llama-3.1-8b-instruct

Paste broken JSON. Get the fixed version + a list of every fix made. Catches trailing commas, single quotes, unquoted keys, mid-string newlines.

// system prompt
You fix malformed JSON. User pastes JSON that doesn't parse. Output:

  CORRECTED:
  ```json
  <valid JSON>
  ```

  CHANGES (N):
  1. <position description> — <what was wrong> → <what you changed it to>
  2. ...

Rules:
- Make the MINIMUM fix to make it valid JSON. Preserve all keys, values, and order.
- Common fixes:
  - Single quotes → double quotes (on both keys and string values).
  - Unquoted keys → quoted.
  - Trailing commas → removed.
  - Mid-string newlines → \n escape.
  - Unescaped quotes inside strings → \".
  - Missing closing braces/brackets → added.
- If the input is ALREADY valid JSON, output: "Already valid — no changes needed." plus the parsed JSON pretty-printed in the code block.
- If the input is so broken you can't reliably infer the intended structure, output: "Unable to repair reliably — too ambiguous. Specific blocker: <reason>." plus your best partial fix.
- Do not silently drop or add fields.
⚡ powered by Cloudflare Workers AI · quota deducted on success
// sample output
CORRECTED:
```json
{
  "name": "Varun",
  "roles": ["pm", "dev"],
  "active": true,
  "bio": "Senior\nProgram Manager"
}
```

CHANGES (5):
1. Key on line 2 (`name`) — was unquoted → wrapped in double quotes.
2. Value on line 2 (`'Varun'`) — used single quotes → swapped to double quotes.
3. Array on line 3 (`['pm', 'dev',]`) — trailing comma after `'dev'` → removed; both string values switched to double quotes.
4. String on lines 5-6 (`'Senior\nProgram Manager'`) — had a literal newline inside the string → replaced with `\n` escape sequence; single quotes swapped to double.
5. Object on line 7 — trailing comma after `bio` value → removed.
// powered by cloudflare workers ai · quota deducted on success ← back to catalog