SQLite is the database inside most phones, browsers and desktop programs: Firefox keeps its history in places.sqlite, Chrome in a file called History, Plex and Jellyfin keep their libraries in SQLite, and so do Lightroom catalogs, iPhone messages and countless apps. When a copy is interrupted, a disk fails or a program is killed at the wrong moment, the file can be left damaged, and opening it fails with "database disk image is malformed", "file is not a database" or "database corruption".
This page runs SQLite itself, version 3.54, compiled to WebAssembly, with SQLite's recovery extension: the same code as the sqlite3 command-line program's .recover command, which is the usual answer to a corrupt database. It reads the file page by page, takes every row it can still read, and writes them into a new database with the original's tables, indexes and settings. Rows it finds but cannot place in a table go to a lost_and_found table rather than being dropped. It is free to use, with no account and no upload limit, and it runs entirely in your browser: nothing is uploaded, and while the page stays open, a feature you have already used keeps working offline.
Recovery saves what is still in the file. Rows on pages that were overwritten, zeroed or cut off are gone, and so is anything deleted before the damage happened; no tool can bring back data that is no longer in the file. Indexes are rebuilt from the recovered rows rather than copied, so they always match the tables. Check the recovered data in the program that uses it before deleting anything, and always keep the original.
- How do I fix "database disk image is malformed"?
- That message means SQLite found a page it cannot make sense of. Drop the database here and press Recover: everything still readable is copied into a new database, which you download and put in place of the damaged one while the program that uses it is closed. On a computer with the sqlite3 program, the equivalent is
sqlite3 damaged.db ".recover" | sqlite3 recovered.db. - Is this the same as the sqlite3 .recover command?
- Yes. It is SQLite's own recovery extension (sqlite3recover), the code the .recover command runs, built from the official SQLite 3.54.1 source. The Download as SQL button gives the same kind of script as
sqlite3 damaged.db .recover. - What is the lost_and_found table?
- When a damaged page means a row can no longer be traced to its table, recovery puts it in lost_and_found instead of dropping it. Each row records the page it was found on, the root page of the table it seems to belong to where that is known, its number of fields, its rowid and its values in columns c0, c1 and so on, so you can copy rows back by hand. Untick the option to leave such rows out.
- When should I use Make a clean copy instead of Recover?
- When the checks report no problems but the database is large, slow or full of free space, a clean copy (VACUUM INTO) rebuilds it compactly with everything in it. It reads the database through SQLite in the normal way, so it stops at the first damaged page: for a damaged database, use Recover.
- What are the -wal and -journal files next to my database?
- A file ending in -wal is a write-ahead log: recent changes not yet copied into the database itself. One ending in -journal holds the original pages of a transaction that was under way, so it can be undone. Choose either together with the database and it is applied as SQLite would on opening it; the result is the database as the program last saw it. A -shm file is only an index of the -wal file and is not needed.
- Can it open an encrypted database?
- No. Databases encrypted with SQLCipher or similar (Signal, WhatsApp's .crypt14 and .crypt15 backups, some password managers) need their key, and without it look like random bytes. The page says so when a file looks encrypted.
- How large a database can it repair?
- Checking and browsing read the file in place, so any size works. The recovered or cleaned database is built in this tab's memory before it is downloaded, which works well up to about 1 GB; beyond that, depending on the computer, the browser may run out of memory and the page says so. A -wal or -journal file means the database is copied into memory too, up to 1 GB together.
- Is my database uploaded anywhere?
- No. SQLite runs inside this browser tab, reading the file from your disk; nothing is sent anywhere, and the original is never changed.