JSON repair: fix invalid JSON
About JSON Repair
JSON Repair turns almost-JSON into strict, readable JSON. It fixes the mistakes you see in copied config, JavaScript object literals and hand-edited API fixtures. That covers comments, trailing commas, single-quoted strings, unquoted keys and non-JSON literals such as undefined, NaN or Python-style booleans.
Runs in your browser. Nothing is uploaded. The input is treated as text and never evaluated as JavaScript, so constructors and expressions are not run.
The repair is conservative on purpose. It applies a fixed set of changes, then runs the result through the native strict JSON parser. If the result is still ambiguous or incomplete, the tool reports the remaining syntax error. It does not guess at a structure that could change what your data means.
How it works
Normalize common JSONC and object-literal syntax
Line and block comments are removed. Comment-like text inside strings is left alone. Single-quoted strings become JSON strings, bare object keys get quotes, and trailing commas before a closing brace or bracket are removed.
Repair familiar non-JSON literals
undefined, NaN, Infinity and None become null. Common Python boolean spellings become JSON booleans. This helps with copied debug output. Review the null replacements, because null cannot keep a non-finite number.
Validate and format the repaired result
After the text fixes, the browser parses the result as strict JSON and prints it with your chosen indentation. That final parse is the safety check. You only see output when it is valid JSON.
Know when a manual decision is required
The tool does not rebuild badly truncated documents, expressions, computed properties or ambiguous punctuation. The parser message points to the spot where you need to decide.
Frequently asked questions
What kinds of invalid JSON can this tool repair?
Comments, trailing commas, single quotes, unquoted keys, code fences, some missing commas at line ends and several common non-JSON literals. It cannot recover every damaged document.
Does JSON Repair execute JavaScript?
No. It applies text changes and then calls JSON.parse. Functions, constructors and expressions are never evaluated.
Why was NaN or undefined changed to null?
Strict JSON cannot represent either value, so the repairer uses null. Check those fields if the difference matters to your app.
What should I do if automatic repair fails?
Go to the reported error location and fix that part by hand. A truncated string, an unmatched bracket or an executable expression usually needs context that an automatic pass cannot infer safely.
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.