JSON Repair Tool
Turns almost-JSON into valid JSON — and shows exactly what it changed.
Changes
What changed (character diff)
Removed text and added text are marked in your original text.
About the JSON Repair Tool
Paste text that is almost JSON — a JavaScript object, a JSON5 or JSONC config file, a Python print() of a dict, a line from a log, or an answer from a chatbot that stopped halfway — and get strict RFC 8259 JSON back. The repair keeps your layout and changes only what has to change, and every change is listed with its line and column, so nothing happens behind your back. A character diff shows the edits in place.
The result is always checked with a strict JSON parser before it is shown: if the tool says it repaired the text, the output is valid JSON. Numbers keep every digit, and everything runs in your browser — the page works offline, and nothing you paste is uploaded.
How to use it
- Paste the broken JSON, open or drop a file, or choose a sample. It is repaired as you type (or press Repair JSON, or Ctrl/⌘ + Enter).
- Read the status: how many changes were made, and how many are guesses — such as closing a string that was cut off or treating a stray quote as text — which are marked as warnings.
- Go through Changes: Show selects the original text in the editor. Open What changed to see a character diff of your text and the repaired one.
- Choose the layout of the result — your original layout, 2 or 4 spaces, tabs or one line — and optionally sort the keys.
- Copy or download the JSON, or press Open in JSON Formatter to keep working on it.
Examples
{
name: 'my-smart-copilot',
port: 0x1F90, // http
tags: ['a', 'b',],
}{
"name": "my-smart-copilot",
"port": 8080,
"tags": ["a", "b"]
}{'id': 42, 'online': True, 'error': None, 'readings': (21.5, 22.0)}{"id": 42, "online": true, "error": null, "readings": [21.5, 22.0]}```json
[{"id": 1, "title": "Billing"}, {"id": 2, "title": "Sea[{"id": 1, "title": "Billing"}, {"id": 2, "title": "Sea"}]The closing quote, } and ] are added and marked as guesses: the text really ended there, so check whether more data was lost.
{"level":"info","ms":12}
{"level":"warn","ms":812}[{"level":"info","ms":12},
{"level":"warn","ms":812}]Common uses
- Turning a JavaScript or TypeScript object literal into JSON for an API, a fixture or a config file.
- Recovering usable data from LLM and chatbot answers that wrapped the JSON in prose or a code fence, or stopped mid-way.
- Converting Python
print()output, MongoDB shell output or JSON5 / JSONC configuration into strict JSON. - Cleaning up JSON copied from logs: escaped quotes, several objects in a row, stray commas.
What it fixes
- JavaScript and JSON5 (spec.json5.org): comments, trailing commas, unquoted keys, single-quoted and backtick strings, hexadecimal and binary numbers,
+1,.5,5.,1_000,undefined,NaNandInfinity(which JSON cannot hold, so they becomenullwith a warning), line continuations and escapes such as\x41and\u{1F600}. - Python:
True,False,None, tuples( … )andu'…'/r'…'strings. - Damaged JSON: missing commas, colons, quotes and closing brackets; a
]where a}belongs; unescaped quotes and line breaks inside strings; curly quotes from word processors; text cut off at any point. - Wrappers and surroundings: Markdown code fences, text before or after the JSON,
callback( … )(JSONP), MongoDB'sObjectId("…")andISODate("…"), several JSON values in a row (wrapped into one array, as for JSON Lines), and JSON that was escaped as a string ({\"a\": 1}).
Guesses are marked
Some repairs are certain — a trailing comma or a comment can only be removed. Others are guesses, and they are listed as warnings so you can check them: a string or bracket closed because the text ended, a quote treated as part of the text, unquoted text such as active turned into the string "active", a number with leading zeros such as 007 kept as the string "007" (it is often a code), NaN and Infinity replaced with null, and anything that was removed — text around the JSON, or characters that fit nowhere.
An unknown escape such as \U in "C:\Users" keeps its backslash ("C:\\Users"), because Windows paths and regular expressions are the usual reason for it.
Keeping your layout
With Original layout, everything that needs no change — spaces, line breaks, the order of keys, the digits of every number — is copied as it is, so the character diff shows only real edits. A removed comment leaves its line break behind. Choose 2 spaces, 4 spaces, tabs or one line to re-print the repaired JSON; numbers are still kept exactly as written (12345678901234567890 is not rounded, 1.50 stays 1.50).
Limitations
- A repair is a best effort: when the text is ambiguous the tool picks the most likely reading and marks it as a guess, but it cannot know what was meant — check the warnings before you use the result.
- Data that was cut off is not recovered: the tool closes what is open, so the last item may be incomplete.
- JavaScript code is not run: expressions such as 1 + 2, variables and function calls other than simple wrappers are not evaluated.
- The character diff is shown for texts up to about 500,000 characters with up to about 50,000 changed places; larger repairs are still listed change by change.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Is my JSON uploaded?
No. The repair runs entirely in your browser, and the page works offline once it has loaded.
How is this different from a JSON validator?
A validator tells you where the first error is; this tool fixes everything it can in one go and tells you what it did. To check strict JSON with every warning, use the JSON Validator.
Can it convert JSON5 or JSONC (JSON with comments) to JSON?
Yes. Comments, trailing commas, unquoted keys, single quotes, hexadecimal numbers and the other JSON5 features are converted to strict JSON. Note that JSON has no NaN or Infinity, so those become null.
Why did my value become null?
JSON cannot hold NaN, Infinity or undefined, and a key with no value needs one; the tool puts null there and lists it as a warning. Replace it with a real value if you know it.
My JSON is in quotes with \" everywhere. Can it unescape it?
Yes. Text such as {\"a\": 1} is unescaped automatically. If the whole thing is a valid JSON string ("…"), it is already valid JSON — the tool says so and offers to unwrap the JSON inside it.