Home › Developer Tools › JSON Repair Tool

JSON Repair Tool

Paste broken JSON and get valid JSON back instantly. Trailing commas, single quotes, comments, unquoted keys, Python and JavaScript values, code fences and cut-off data are fixed, and a fix list and diff show exactly what changed.

Last updated:

Ready.
Advertisement
Advertisement

How to use the JSON Repair Tool

  1. Paste your broken JSON into the left box, open a file, or pick an example such as AI chat output or a Python dict.
  2. Read the repaired JSON on the right. It updates as you type; press Repair JSON or Ctrl + Enter if live repair is off.
  3. Review the fixes in the fix list, or switch to Diff to see removed text in red and added text in green. Click a fix to select it in your input.
  4. Choose the output layout: keep your original formatting, pretty-print or minify.
  5. Copy or download the repaired JSON, or press Use as input to keep editing it.

What gets repaired

ProblemBroken inputRepaired output
Trailing comma[1, 2, 3,][1, 2, 3]
Missing comma["a" "b"]["a", "b"]
Single or curly quotes{'id': ‘a1’}{"id": "a1"}
Unquoted key or value{status: active}{"status": "active"}
Comments{"a": 1 /* note */}{"a": 1 }
Python / JavaScript values{"ok": True, "x": None, "y": undefined}{"ok": true, "x": null, "y": null}
Quote inside a string"He said "hi" to me""He said \"hi\" to me"
Raw line break in a string"line 1↵line 2""line 1\nline 2"
Truncated input{"items": ["pen", "pap{"items": ["pen", "pap"]}
Wrapperscallback({"a": 1});, ObjectId("64f1…"){"a": 1}, "64f1…"
Code fences and preambles```json { … } ```{ … }
Escaped (stringified) JSON"{\"a\":1}"{"a":1}
Line-delimited JSON{"a":1}↵{"a":2}[{"a":1},↵{"a":2}]
Non-JSON numbers.5, +3, 0x1F, 0070.5, 3, 31, "007"

Where broken JSON comes from

AI and chat output is the most common source today: language models wrap JSON in Markdown code fences, add a sentence before it, use Python-style True and None, or stop mid-object when they hit a length limit. Hand-written config files pick up comments and trailing commas because JavaScript, JSON5 and many editors allow them. Copied code brings JavaScript object literals with unquoted keys and single quotes, Python print(dict) output, or MongoDB shell results full of ObjectId() and ISODate(). Logs and exports are often one JSON object per line, or are cut off when a file was rotated or a request timed out.

How the repair works

The repair reads your text the way a forgiving parser would. Wherever strict JSON (RFC 8259) would fail, it applies the most likely fix: it inserts a missing comma, swaps a quote character, closes an open string, drops a comment, and so on, while leaving everything else, including your whitespace and line breaks, untouched. The result is checked with the browser's own strict JSON.parse, so a green status means any standard JSON parser will accept it.

The fix list and diff compare your input with the repaired text in its original layout, word by word, so formatting changes never hide the real fixes. If a guess was wrong, typically with quotes inside strings, edit the input and the output updates instantly.

Frequently asked questions

What kinds of broken JSON can be repaired?

Syntax problems with a clear intended meaning: trailing commas, missing commas or colons, single or curly quotes, unquoted property names and values, comments, unescaped quotes and line breaks inside strings, Python True/False/None, JavaScript undefined and NaN, MongoDB shell types such as ObjectId() and NumberLong(), JSONP callbacks, Markdown code fences, escaped JSON strings, line-delimited JSON and missing closing brackets.

Can it fix truncated JSON?

Yes. When the input stops in the middle, for example because an AI response or a log line was cut off, open strings are closed, a missing value becomes null and all open arrays and objects are closed. The structure becomes valid, but data that was never received cannot be recovered, so check the end of the result.

Will the repair change my data?

Only the syntax is changed. Values stay the same, except that values JSON cannot represent are converted: undefined, NaN and Infinity become null, numbers with leading zeros such as 02134 become strings so the zeros are kept, and hexadecimal numbers become decimal. The fix list shows every change.

Which engine does the tool use?

It loads the open-source jsonrepair library (version 3.8.0) in your browser. If the library cannot load or cannot repair the input, a built-in repair engine handles it instead. The status bar shows which engine produced the result.

How is this different from a JSON validator?

A validator tells you where the first error is so you can fix it by hand. A repair tool fixes all the errors it can in one go and shows what it changed. To find and fix errors one at a time, use the JSON Validator.

Why does my result differ from what I expected?

Some inputs are ambiguous. A quote inside a string can either end the string or be part of the text, and the repair has to guess from what follows it. Review the diff, adjust the input where the guess was wrong and the output updates instantly.

Is my data uploaded?

No. Repairing, diffing and formatting all run in JavaScript on your device. Nothing you paste or open is sent to a server.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.JSON CompareCompare two JSON documents and see every added, removed and changed path.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.XML to Excel ConverterTurn repeating XML elements into an .xlsx spreadsheet with attributes and nested data as columns.XSD to XML Sample GeneratorGenerate a sample XML document from an XSD schema, with types, attributes and namespaces.YAML to CSV ConverterTurn a YAML list of objects into CSV with dot-notation columns, custom column order and download.DOCX to Markdown ConverterConvert Word .docx to clean Markdown with headings, lists, tables, links and images in a ZIP.ES6 to ES5 ConverterTranspile modern JavaScript (ES2015+) to ES5 with Babel: targets, module format and loose mode.JavaScript Object to JSONTurn JS object literals and Python dicts into valid JSON: quotes keys, fixes commas and values.JSON Graph VisualizerSee JSON as an interactive node graph with zoom, collapse and search; export PNG or SVG.KML ViewerOpen KML and KMZ files on an interactive map: placemarks, paths, polygons, folders, export.MySQL to PostgreSQL ConverterConvert MySQL dumps and CREATE TABLE statements to PostgreSQL: types, AUTO_INCREMENT, ENUMs, quotes.Text to CSV ConverterTurn space-aligned, fixed-width, pipe or tab separated text into clean CSV with a live preview.VCF File ViewerOpen vCard .vcf files as contact cards with photos, search and duplicate check, export CSV.XML ViewerBrowse XML as a collapsible tree with search, XPath of any node, attributes and big-file support.JSON to C# ClassConvert JSON to C# classes or records with System.Text.Json or Newtonsoft attributes.JSON SorterSort JSON keys A-Z recursively, sort arrays by value or by a key, then pretty-print or minify.JSON to HTML TableConvert a JSON array of objects into clean HTML table code with CSS styles and a live preview.
See all 129 Data & File Format Converters →