Skip to content

JSON Fixer

Paste JSON that will not parse, whether it came from an AI model, a log file or a hand-edited config, and click Fix JSON. The tool removes code fences and surrounding text, repairs the usual syntax mistakes, formats the result and tells you what it detected. Nothing is uploaded.

Loading editor...
Paste broken JSON
Loading editor...
Output
Ctrl+Enter Fix JSON

How to fix invalid JSON

  1. Paste the broken text into the left panel, upload a file (up to 5 MB) or use Load from URL. Click Sample to see a typical AI reply with a code fence, a comment, single quotes and a Python True.
  2. The error bar shows where the original fails to parse. Click Fix JSON or press Ctrl+Enter.
  3. The repaired, formatted JSON appears on the right with a message such as Fixed: Removed markdown code fence, Trailing comma before } or ], Single-quoted strings or keys. If the input was already valid, it says so.
  4. Review the result in Tree or Code view, pick an indent (2, 3, 4 spaces or tab), then Copy or Download .json.

What it repairs

Example input, pasted straight from a chat window:

Here is the JSON you asked for:
```json
{
  // customer record
  'name': 'Maya Patel',
  "roles": ["admin", "editor",],
  "active": True
}
```
Let me know if you need anything else.

Output:

{
  "name": "Maya Patel",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}

Message: Fixed: Removed markdown code fence, Trailing comma before } or ], Single-quoted strings or keys, Comments, Non-JSON literals (True/False/None/NaN/undefined).

The same pass also handles unquoted keys, curly quotes copied from a document, a UTF-8 byte order mark at the start of a file, and brackets that were never closed.

Limits and notes

  • Review before you use the result. The fixer repairs syntax and leaves your strings and numbers as written, but the repair is heuristic and the notes name the categories it detected rather than every individual edit. Your input stays untouched on the left so you can compare.
  • Truncated output is closed where the text ends, so the final value may be incomplete. The note tells you how many brackets were missing.
  • Literal translations are the only value changes: True and False become true and false, None becomes null, and NaN becomes the string "NaN" so nothing is dropped silently.
  • One document at a time. If a reply contains several fenced blocks, only the first is used; split them and fix each separately.
  • Files up to 5 MB. Everything runs in your browser; nothing is sent to a server.
  • Comments are removed, not preserved, because JSON has no comment syntax.
  • To understand the original error message, see common JSON errors and Unexpected token in JSON. For model output specifically, read how to fix AI-generated JSON, and for the most frequent single mistake, trailing commas.

Frequently Asked Questions

What kinds of broken JSON can it repair?
Markdown code fences and prose around the JSON, trailing commas, single-quoted strings and keys, curly smart quotes, // and /* */ comments, unquoted keys, Python literals such as True and None, a leading byte order mark, and output that was cut off before its closing brackets.
Does it change my data?
It repairs syntax, not content. Strings and numbers are left as written. The only value edits are literal translations: True and False become true and false, None becomes null, and NaN, which JSON cannot represent, becomes the string "NaN". The notes list each category it detected so you can review.
My AI response has text before and after the JSON. Do I have to delete it?
No. Paste the whole reply. The first fenced code block is extracted, or if there is no fence, everything before the first { or [ and after the last } or ] is dropped. The notes say which of these happened.
What happens with truncated output?
Missing closing brackets and quotes are added where the text ends, and the note reports how many brackets were missing. The content that was cut off is gone, so check the last value; it may be an incomplete string or a shorter array than you expected.
The result is not what I expected. What should I check?
The repair is heuristic: where the text is ambiguous it picks the most likely reading. Your original stays in the left panel, so compare the two side by side. If the input cannot be repaired at all, the error bar explains why.
Is my data uploaded?
No. Repair and formatting run as JavaScript in your browser tab. You can disconnect from the network after the page loads and the tool keeps working.

Guides that go with this tool

More JSON tools

JSON Viewer (Tree View)

Explore any JSON document as a collapsible tree in your browser. Click a key to copy its JSONPath, click a value to copy it, and page through large arrays without freezing the tab.

JSON to CSV Converter

Convert a JSON array of objects to CSV in your browser. Nested objects are flattened to dotted columns, values are quoted correctly, and Excel-friendly output is one click away.

CSV to JSON Converter

Convert CSV with a header row into a JSON array of objects in your browser. Numbers and booleans are detected, leading-zero codes stay strings, and the delimiter is picked up automatically.

JSON to YAML Converter

Convert JSON to clean YAML in your browser with 2, 3 or 4 space indentation. Strings that a YAML parser would read as numbers, booleans or dates are quoted so they survive the round trip.

YAML to JSON Converter

Convert YAML to JSON in your browser. Multi-document files become an array, anchors and aliases are resolved, and only null, true, false and plain numbers are typed, so yes, NO and dates stay strings.

JSON to XML Converter

Convert JSON to XML in your browser. Choose the root and array item element names, nulls become xsi:nil, keys are sanitised into valid XML names, and text is escaped.

XML to JSON Converter

Convert XML to JSON in your browser. Attributes are kept as @_name keys, repeated tags become arrays, numbers and booleans are detected, and invalid XML reports the line and column.

JSON Compare (Diff)

Compare two JSON documents in your browser and get a structural diff that lists every changed, added, and removed value with its JSONPath. Key order and whitespace are ignored.

JSONPath Query Tester

Test JSONPath expressions against your JSON in the browser. Pick an expression, see the matches as a JSON array with a count, and explore the results in tree view.

JSON Escape / Unescape

Escape text into a JSON string literal, unescape one back to plain text, or stringify a whole JSON document to embed it inside another JSON value or in source code.