Skip to content

Instantly share code, notes, and snippets.

@rmehner
Last active July 9, 2024 10:35
Show Gist options
  • Save rmehner/b9a41d9f659c9b1c3340 to your computer and use it in GitHub Desktop.
Save rmehner/b9a41d9f659c9b1c3340 to your computer and use it in GitHub Desktop.
Delete all indexedDB databases
// Credit to @steobrien from https://gist.github.com/rmehner/b9a41d9f659c9b1c3340#gistcomment-2940034
// for modern browsers, this works:
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
// for older browsers, have a look at previous revisions of this gist.
@igwejk
Copy link

igwejk commented Feb 21, 2022

Remember to wrap the execution in an async function.

(async () => {
    const dbs = await window.indexedDB.databases();
    dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) });
})();

This works fine for me on Safari. Note that you may not see the effect immediately on the dev tool until you close the browser window and open it again.

@cindywu
Copy link

cindywu commented May 3, 2022

🙏🏽

@LynetteCullens
Copy link

Here's a condensed one-liner if you just want something to copy and paste into your browser console: indexedDB.databases().then(dbs => dbs.forEach(db => indexedDB.deleteDatabase(db.name)))

Just commenting so that I can always find this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment