About Online JSON Fixer
Paste invalid JSON into the Source JSON field and press Fix: the result box shows the repaired JSON, indented, and the source stays as you typed it. Strings are left untouched, and numbers are copied as typed, so 18.00 stays 18.00. Format indents JSON without repairing it, and Minify puts valid JSON on one line.
- Fix single quotes, unquoted keys and trailing commas
- Remove // and /* */ comments
- Replace Python True, False and None with true, false and null
- Keep strings and numbers as typed
- Show the first parse error with its line number when JSON cannot be repaired
- Format and minify JSON
- Upload a JSON file from your disk
- Download the repaired JSON as a .json file
- Free to use
What is JSON repair?
JSON repair turns text that is almost JSON into valid JSON: it rewrites what the JSON standard, RFC 8259, does not allow and keeps the data. Single quotes become double quotes, keys get quotes, trailing commas and comments are removed, and Python's True, False and None become true, false and null.
Why does JSON break?
JSON is strict, and the text pasted into it often comes from places that are not: a JavaScript object with unquoted keys and single quotes, a Python dict printed with True and None, a config file with comments, or a hand edit that leaves a comma after the last item. A JSON parser rejects all of them.
How to fix JSON online?
Paste JSON into the Source JSON field, or press Upload to open a .json file, then press Fix. The repaired JSON appears in the result box; copy it or press Download to save it as data.json. If the text cannot be repaired, the result box shows the first parse error and the line it is on.
How does the JSON fixer work?
The page first checks whether the JSON is already valid: valid JSON is not changed, only indented. Otherwise it runs the open-source jsonrepair library in your browser and checks its output with a JSON parser again. Only output that parses is shown; if the repair fails, you see the parse error of the original text. Nothing inside a string is changed, so a // or a single quote within a value stays.
JSON Fix Example
Below is an example of invalid JSON and the repaired result.
JSON Repair Rules
- Single-quoted strings and keys get double quotes.
- Unquoted keys get double quotes.
- A trailing comma after the last item of an object or array is removed: RFC 8259 does not allow it.
- // and /* */ comments are removed: JSON has no comments.
- Python True, False and None become true, false and null.
- A missing value becomes null: {"a": } turns into {"a": null}.
- Strings, numbers and key order are kept as typed.
- Text that is not JSON, such as XML, is not repaired: the result box shows the parse error.
How to fix JSON in JavaScript and Python?
In JavaScript, the jsonrepair package, which this page uses, returns valid JSON text from jsonrepair(text). In Python, the json_repair package does the same with repair_json(text). Both return a string; parse it with JSON.parse or json.loads.
Online JSON Formatter
To format valid JSON with 2 spaces, 4 spaces or tabs and view it as a collapsible tree, use the JSON Formatter.