JSON Repair
Fix broken JSON automatically. Paste, repair, copy.
How to Use the JSON Repair Tool
- Paste your broken JSON into the input panel on the left. This can be malformed output from an LLM, a Python dictionary, a config file with comments, or any JSON-like text that fails to parse.
- Click the “Repair” button (the arrow between the panels) to run automatic repair. The tool applies a series of fixes in order, from comment removal to bracket balancing.
- Review the output in the right panel. The repaired JSON is formatted with 2-space indentation for readability.
- Check the fix badges that appear below the editor. Each green badge describes one repair that was applied, such as “Removed trailing commas” or “Converted single quotes to double quotes.”
- Copy the result using the copy button on the output panel. The repaired JSON is valid and ready to use in your application, API call, or configuration file.
What is JSON Repair?
JSON repair is the process of automatically fixing common syntax errors in malformed JSON text so that it becomes valid and parseable. Unlike a JSON formatter, which requires valid JSON as input, the repair tool accepts broken JSON and attempts to fix it.
The most common sources of broken JSON are:
- LLM output: ChatGPT, Claude, and other language models frequently generate JSON with trailing commas, single quotes, unquoted keys, and inline comments. These are valid in JavaScript but not in JSON.
- Copy-paste from code: Copying a JavaScript or Python object literal into a JSON context introduces syntax that JSON does not support, such as single quotes,
True/False/None, or template literals. - Hand-edited config files: Developers editing JSON config files by hand often add comments for documentation, forget trailing commas, or miss closing brackets.
- Truncated responses: API timeouts or network errors can truncate a JSON response mid-stream, leaving unclosed brackets and braces.
This tool applies a sequence of regex-based transformations to fix these issues, then validates the result with JSON.parse(). If the repaired text parses successfully, you get clean formatted JSON. If it cannot be repaired, you get a descriptive error message.
Examples
1. Fixing LLM output with trailing commas and single quotes
A language model returns this response:
{
'name': 'Alice',
'age': 30,
'skills': ['python', 'javascript',],
}After repair, the tool produces valid JSON:
{
"name": "Alice",
"age": 30,
"skills": [
"python",
"javascript"
]
}Fixes applied: Converted single quotes to double quotes, Removed trailing commas.
2. Python dictionary pasted as JSON
You copy a Python dictionary from a script:
{'enabled': True, 'count': None, 'debug': False}After repair:
{
"enabled": true,
"count": null,
"debug": false
}Fixes applied: Converted Python True/False/None to JSON, Converted single quotes to double quotes.
3. Config file with comments and missing brackets
A hand-edited configuration file:
{
"host": "localhost", // dev server
"port": 3000,
/* database settings */
"db": {
"name": "myapp"
After repair:
{
"host": "localhost",
"port": 3000,
"db": {
"name": "myapp"
}
}Fixes applied: Removed single-line comments, Removed multi-line comments, Added 1 missing closing brace(s).
Common Use Cases
- Fixing LLM output: When ChatGPT, Claude, or other AI models return JSON with JavaScript-style syntax errors, paste the output here to get valid JSON instantly. This is the most common use case for JSON repair.
- Debugging API payloads: When an API request fails because the JSON body is malformed, paste the payload here to identify and fix the issues before retrying.
- Cleaning hand-edited configs: JSON configuration files (
package.json,tsconfig.json,.babelrc) do not support comments. If you or a teammate added comments for documentation, this tool strips them while preserving the configuration data. - Migrating from JavaScript to JSON: JavaScript object literals use features that JSON does not support — unquoted keys, single quotes, trailing commas, and template literals. This tool bridges the gap when you need to convert a JS object to strict JSON.
- Converting Python dicts: Python dictionaries printed with
print()or logged to console useTrue,False,None, and single quotes. Paste them here to get valid JSON for use in APIs, configs, or other JSON-consuming tools. - Recovering truncated data: If a JSON response was cut off mid-stream (API timeout, network error, buffer overflow), this tool attempts to close any unclosed brackets and braces to make the partial data parseable.
What Errors Does It Fix?
The JSON repair tool handles these specific issues:
| Issue | Before | After |
|---|---|---|
| Trailing commas | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Single-line comments | {"a": 1} // comment | {"a": 1} |
| Multi-line comments | {"a": 1 /* x */} | {"a": 1} |
| Python booleans | True / False | true / false |
| Python None | None | null |
| JavaScript undefined | undefined | null |
| NaN values | NaN | null |
| Missing closing braces | {"a": 1 | {"a": 1} |
Frequently Asked Questions
What JSON errors can the repair tool fix?
The tool fixes trailing commas, single quotes instead of double quotes, unquoted object keys, missing closing brackets and braces, single-line and multi-line comments, Python-style True/False/None values, JavaScript undefined and NaN values. These cover the vast majority of malformed JSON encountered in real-world development.
Is it safe to use the JSON repair tool on sensitive data?
Yes. All repair processing runs entirely in your browser using JavaScript. Your JSON data never leaves your machine. There are no server requests, no cookies, and no data storage. You can verify this by checking the Network tab in your browser DevTools.
What happens if the tool cannot repair my JSON?
If the JSON is too malformed to repair automatically, the tool displays an error message explaining what went wrong. You can use the error details to manually fix the remaining issues. The tool still shows which fixes it attempted before failing, so you know what was already corrected.
Does the repair tool change my data?
The tool only fixes structural syntax errors. It does not modify your actual data values, reorder keys, or remove properties. The only value substitutions are converting undefined and NaN to null, and True/False/None to true/false/null — since these are the closest JSON equivalents.
How is this different from a JSON validator or formatter?
A JSON formatter requires valid JSON as input — it reformats the whitespace but cannot fix syntax errors. A JSON validator tells you whether JSON is valid and where errors are. This repair tool goes further: it takes broken JSON and actually fixes it. Use the formatter for already-valid JSON; use this tool when your JSON is broken.
Can it fix JSON output from ChatGPT or other LLMs?
Yes. LLMs frequently produce JSON with trailing commas, single quotes, comments, and unquoted keys. This tool was specifically designed to handle these common LLM output issues. Paste the LLM response directly and click Repair.
Does it handle Python dictionaries pasted as JSON?
Yes. Python dictionaries use True, False, None, and single quotes — all of which are invalid in strict JSON. The repair tool converts these to their JSON equivalents: true, false, null, and double quotes.
Related Tools
Privacy & How It Works
This JSON repair tool runs 100% client-side in your browser. When you click Repair, your input is processed using a series of regex transformations and then validated with the browser’s built-in JSON.parse() function. No data is transmitted to any server, no cookies track your usage, and nothing is stored after you close the tab. This makes the tool safe for repairing sensitive data such as API keys, authentication tokens, database connection strings, and private configuration files. You can verify this by opening your browser’s Network tab — you will see zero outgoing requests when repairing. For related tools, try the JSON Formatter for valid JSON formatting, the JSON Viewer for interactive tree exploration, the JSON Diff for comparing two JSON documents, or the JSONL Viewer for JSON Lines files.