IDBObjectStore.delete() removes one or more records from an IndexedDB object store. Pass a primary key or an IDBKeyRange. To empty a store without dropping it, use clear(). To drop the store itself, call deleteObjectStore() during a version upgrade.
Deletes run inside a readwrite transaction. Pair this with retrieve to list keys first, and insert to add fresh data afterward.
Baseline · Widely available.
Not deprecated. IndexedDB delete() has been stable across browsers since about July 2015. Also available in Web Workers.
Related APIs.
clear() wipes all rows in a store. IDBCursor.delete() removes the current cursor row without looking up the key again. indexedDB.deleteDatabase() removes the whole database for the origin.
Syntax
Syntax
syntax.js
store.delete(key)
Call delete() on an object store from a readwrite transaction. For every record in the store: store.clear(). For the store itself: db.deleteObjectStore(name) inside onupgradeneeded.
Reference
Parameters
The delete() method takes one argument:
Parameter
Type
Description
key
Key or IDBKeyRange
Primary key of the record to remove, or a key range to remove several records. Required (do not pass null).
The key type must match the store’s keyPath (number, string, etc.). clear() takes no parameters.
Result
Return Value
Returns an IDBRequest. On success, request.result is undefined—there is no count of deleted rows. Listen with request.onsuccess / request.onerror, or wait for transaction.oncomplete.
Exception
When it is thrown
ReadOnlyError
Transaction mode is readonly
TransactionInactiveError
The transaction is no longer active
DataError
The key or key range is invalid
InvalidStateError
The object store was deleted
Flow
How It Works
A typical single-record delete follows these steps:
Open the database with indexedDB.open(name, version).
Start a write tx: db.transaction(['store'], 'readwrite').
Get the store: tx.objectStore('store').
Call delete(key) (or clear() for all rows).
Handle success or error on the request; the change commits when the transaction completes.
On button click, run store.delete(1) in a write transaction.
Update the status text so the user sees the result without the console.
Edge Cases & Pitfalls
Most delete bugs come from the wrong transaction mode or assuming a missing key fails.
mode
Need readwrite
delete() and clear() throw ReadOnlyError in a readonly transaction.
silent
Missing keys succeed
Deleting a key that was never stored does not error. Use get() when you need existence checks.
schema
Drop stores only on upgrade
deleteObjectStore() works only inside onupgradeneeded with a higher version number.
safety
No undo after commit
Confirm destructive actions—especially clear() and deleteDatabase()—in the UI first.
cursor
Prefer cursor.delete when iterating
While walking with openCursor(), cursor.delete() removes the current row without a separate key lookup.
Compatibility
Browser Support
IndexedDB delete(), clear(), and related APIs are standard Web Storage features in modern browsers—not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
IndexedDB delete()
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support delete(), clear(), and deleteObjectStore() during upgrades.
96%Global support (approx.)
Google Chrome24+
Full support
Mozilla Firefox16+
Full support
Apple Safari10+
Full support
Microsoft Edge12+
Full support
Opera15+
Full support
Samsung Internet1.5+
Full support
Internet Explorer10+
Partial / older
IndexedDB delete()Widely supported
Bottom line: Safe to use IndexedDB deletes in production web apps. Prefer feature detection with window.indexedDB for very old browsers.
Remember
Key Takeaways
One record:store.delete(key) inside a readwrite transaction.
All records:store.clear() keeps the store schema and indexes.
Silent miss: deleting a missing key still succeeds—check with get() when needed.
Schema: drop stores only with deleteObjectStore() during onupgradeneeded.
One line: delete with store.delete(key) in a readwrite transaction; confirm before clear().
Frequently Asked Questions
Open a readwrite transaction on the object store, then call store.delete(key) with the record's primary key. Example: store.delete(1) removes the record whose keyPath value is 1.
delete(key) removes one record (or a key range). clear() removes every record in the store but keeps the store and its indexes. Use clear() to empty a store; use delete() for specific keys.
delete() still succeeds. There is no error and no "rows affected" count. Call store.get(key) first if your UI needs a "not found" message.
IndexedDB only allows write operations (delete, clear, put, add) inside readwrite transactions. A readonly transaction throws ReadOnlyError.
Bump the database version in indexedDB.open(name, newVersion) and call db.deleteObjectStore('storeName') inside onupgradeneeded. That is a schema change, not a normal transaction.
No. After the transaction commits, the data is gone unless you kept a backup or can re-fetch from a server. Confirm destructive actions in the UI first.