Delete key-value pairs

Last updated Jun 22, 2026 To delete a key-value pair, call the delete() method of the KV binding on any KV namespace you have bound to your Worker code:

env.NAMESPACE.delete(key);
self.env.NAMESPACE.delete(key)

Example

An example of deleting a key-value pair from within a Worker:

export default {
  async fetch(request, env, ctx) {
    try {
      await env.NAMESPACE.delete("first-key");

      return new Response("Successful delete", {
        status: 200
      });
    }
    catch (e)
    {
      return new Response(e.message, {status: 500});
    }
  },
};
from workers import WorkerEntrypoint, Response

class Default(WorkerEntrypoint):
    async def fetch(self, request):
        try:
            await self.env.NAMESPACE.delete("first-key")

            return Response("Successful delete", status=200)
        except Exception as e:
            return Response(str(e), status=500)

Reference

The following method is provided to delete from KV:

delete() method

To delete a key-value pair, call the delete() method of the KV binding on any KV namespace you have bound to your Worker code:

env.NAMESPACE.delete(key);
await self.env.NAMESPACE.delete(key)

Parameters

  • key: string
  • The key to associate with the value.

Response

  • response: Promise<void>
  • A Promise that resolves if the delete is successful.

This method returns a promise that you should await on to verify successful deletion. Calling delete() on a non-existing key is returned as a successful delete.

Calling the delete() method will remove the key and value from your KV namespace. As with any operations, it may take some time for the key to be deleted from various points in the Cloudflare global network.

Guidance

Delete data in bulk

Delete more than one key-value pair at a time with Wrangler or via the REST API.

The bulk REST API can accept up to 10,000 KV pairs at once. Bulk writes are not supported using the KV binding.

Other methods to access KV

You can also delete key-value pairs from the command line with Wrangler or with the REST API.

Was this helpful?

YesNo

On this page

Delete key-value pairs - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/kv/api/delete-key-value-pairs/#page","headline":"Delete key-value pairs","description":"Remove keys and their associated values from a Workers KV namespace using the delete() method.","url":"https://developers.cloudflare.com/kv/api/delete-key-value-pairs/","inLanguage":"en","image":"https://developers.cloudflare.com/kv/api/delete-key-value-pairs/og.png?v=d1c3c8ec4cfb1d93","dateModified":"2026-06-22","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Enumerate all keys in a Workers KV namespace using the list() method, with support for pagination and filtering by prefix. title: List keys image: https://developers.cloudflare.com/kv/api/list-keys/og.png?v=04bfdd69729ab59f


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/kv/llms.txt
Use this file to discover all available pages before exploring further.