JSON Fixer
Repair invalid JSON automatically.
JSON Fixer – Repair Broken JSON Online
Got a "Unexpected token" error and no idea where to start? The JSON fixer repairs invalid JSON automatically. Paste the broken text and get valid, nicely formatted JSON back — no manual hunting for the missing comma or the stray single quote.
What it fixes
- Quotes – adds missing quotes around keys, converts single quotes and typographic “smart quotes” to double quotes, and escapes quotes inside strings.
- Commas – removes trailing commas and inserts missing ones between items.
- Comments – strips
//and/* */comments. - Python and JavaScript literals –
True,False,None,undefined, and string concatenation. - Truncated JSON – closes unclosed strings, arrays, and objects, which is handy for cut-off logs or streamed LLM output.
- Wrappers – JSONP callbacks, Markdown code fences, and MongoDB types such as
ObjectId("...")orISODate("..."). - Special whitespace and control characters that break strict parsers.
Typical situations
Developers often need to turn a JavaScript object literal, a Python dict printed to the console, or a snippet from a chat message into real JSON. Language models also regularly produce JSON with trailing commas or explanations wrapped around it. The fixer handles all of these in one click.
How it works
The tool uses jsonrepair, a well-tested open-source library, and then validates the result with the browser's strict JSON parser. Choose the indentation or minified output; the repaired JSON can be copied or downloaded.
Next steps
After repairing, check the structure in the JSON Viewer, remove empty fields with the JSON Cleaner, or verify the final file with the JSON Validator.
Frequently Asked Questions
What kinds of errors can the JSON Fixer repair?
Missing or single quotes around keys and strings, trailing commas, missing commas, comments, Python constants (True, False, None), unescaped quotes and line breaks in strings, missing closing brackets in truncated JSON, JSONP wrappers, MongoDB types like ObjectId("..."), and concatenated strings from JavaScript code.
Can it always guess what I meant?
It fixes the common, unambiguous mistakes. Badly damaged input may be repaired into something valid that isn't what you intended, so review the output — especially where brackets were missing or text was truncated.
Is the repaired JSON guaranteed to be valid?
Yes. The result is parsed again with the strict JSON parser before it's shown. If the input can't be repaired at all, you get an error with the position where the repair stopped.
Does it work offline and privately?
Yes. The repair runs in your browser with the open-source jsonrepair library; your data is never sent to a server.