How to use the json fixer
- Paste your broken or invalid JSON into the text area.
- The json fixer automatically scans for common syntax errors as you type.
- Review the repaired JSON in the output box.
- Check the list of fixes applied below the output to understand what changed.
- Copy the valid JSON for use in your application or API.
What this json fixer repairs
This tool targets the most frequent mistakes developers make when writing JSON by hand or copying data from other languages. It handles six categories of errors:
- Single quotes: JSON requires double quotes for strings and keys. Single quotes are replaced while preserving escaped characters inside them.
- Unquoted keys: Object keys must be quoted. Bare identifiers like
name:are wrapped in double quotes. - Trailing commas: A comma before a closing bracket or brace is illegal in standard JSON and is removed.
- Comments: Both line comments (
//) and block comments (/* */) are stripped out. - Python literals: The words
True,FalseandNone(when not part of a larger word) are converted totrue,falseandnull. - Missing brackets: If opening brackets or braces are left unclosed at the end of the input, the tool appends the necessary closing characters.
How the repair process works
The json fixer uses a character-by-character state machine rather than simple regular expressions. This matters because naive search-and-replace would corrupt strings that happen to contain comment markers or quote characters. The parser tracks whether it is currently inside a double-quoted string, a single-quoted string, a line comment or a block comment.
For example, consider the input {'url': "http://example.com"}. A regex replacing all single quotes would break the URL. The state machine recognizes that http://example.com is inside double quotes and leaves it untouched, while converting the outer single quotes around url and the value to double quotes. After all transformations, the result is passed through JSON.parse to verify validity. If parsing still fails, the tool reports the exact error instead of silently dropping data.
Common sources of invalid JSON
Invalid JSON usually comes from three places. First, manual editing in a text editor without linting leads to missing commas, extra commas or mismatched brackets. Second, copying data structures directly from Python, JavaScript or Ruby consoles produces output that looks like JSON but uses language-specific syntax such as single quotes, unquoted keys or undefined. Third, configuration files written in relaxed formats like JSON5 or JSONC include comments and trailing commas that strict parsers reject.
This json fixer bridges the gap between these relaxed formats and strict JSON. If you need to go further and convert your repaired JSON to other formats, tools like json to xml or json to sql can transform the valid output into the structure you need.
Reference table of fixes
The following table shows typical broken inputs and how the json fixer transforms them:
| Error type | Input | Output |
|---|---|---|
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted key | {a: 1} | {"a": 1} |
| Trailing comma | [1, 2,] | [1, 2] |
| Line comment | // hi
{"a":1} | {"a":1} |
| Block comment | {/* x */"a":1} | {"a":1} |
| Python True | {"ok": True} | {"ok": true} |
| Python None | {"v": None} | {"v": null} |
| Missing bracket | {"a": [1, 2 | {"a": [1, 2]} |
Limitations and edge cases
While this repair tool handles the vast majority of everyday JSON mistakes, some inputs cannot be fixed automatically. Deeply ambiguous syntax, such as a missing comma between two values where the boundary is unclear, may require human judgment. The tool also does not attempt to fix semantic errors like duplicate keys or incorrect data types; it only addresses syntax.
Unicode escape sequences like \u00e9 are preserved exactly as written. Strings containing escaped single quotes (\') inside single-quoted contexts are handled correctly by converting the escape to a plain single quote within the new double-quoted string. Empty input returns an error rather than producing an empty object, because guessing the intended structure would risk silently dropping data.
Worked examples
| Example | Input | Result |
|---|---|---|
| Single quotes and trailing comma | Broken JSON: {'name': 'Alice', 'age': 30,} | Fixes applied: 2 |
| Unquoted keys and comments | Broken JSON: { / // user info / name: "Bob", / active: true / } | Fixes applied: 2 |
| Python literals | Broken JSON: {"valid": True, "missing": None, "broken": False} | Fixes applied: 3 |
| Missing closing bracket | Broken JSON: {"items": [1, 2, 3] | Fixes applied: 1 |
FAQ
Is my data sent to a server?
No. The json fixer processes everything locally in your browser using JavaScript. Nothing is uploaded anywhere.
Can it fix any broken JSON?
It handles the most common syntax errors including single quotes, unquoted keys, trailing commas, comments, Python literals and missing closing brackets. Severely malformed input that remains ambiguous after these fixes will return a parse error explaining what is wrong.
Does it support JSON5 or JSONC?
Yes. Since JSON5 and JSONC primarily add comments, trailing commas, single quotes and unquoted keys, this tool strips those extensions and produces standard JSON. For dedicated JSONC conversion, see the jsonc to json tool.
Will it change my data values?
No. The tool only modifies syntax characters like quotes and commas. String contents, numbers and nested structures are preserved exactly. Python literals True, False and None are converted to their JSON equivalents true, false and null.
Why does it say the JSON is still invalid?
If the input contains structural problems beyond the six supported fix categories, such as missing commas between values or completely garbled text, the automated repairs may not be enough. The tool will display the specific error from the JSON parser so you can correct it manually.
Can I use the output directly in my code?
Yes. Once the tool confirms the output is valid JSON, you can copy it into configuration files, API payloads or variables. If you need to generate typed classes from it, sibling tools like json to go struct or json to c# class can help.