Skip to content
Cloudflare Docs

Wrangler KV commands

kv namespace

Manage Workers KV namespaces.

kv namespace create

Terminal window
npx wrangler kv namespace create [NAMESPACE]
  • [NAMESPACE] string required

    The name of the new namespace

  • --preview boolean

    Interact with a preview namespace

kv namespace list

Terminal window
npx wrangler kv namespace list

kv namespace delete

Terminal window
npx wrangler kv namespace delete
  • --binding string

    The binding name to the namespace to delete from

  • --namespace-id string

    The id of the namespace to delete

  • --preview boolean

    Interact with a preview namespace

kv namespace rename

Terminal window
npx wrangler kv namespace rename [OLD-NAME]
  • [OLD-NAME] string

    The current name (title) of the namespace to rename

  • --namespace-id string

    The id of the namespace to rename

  • --new-name string required

    The new name for the namespace

kv key

Manage key-value pairs within a Workers KV namespace.

kv key put

Terminal window
npx wrangler kv key put [KEY] [VALUE]
  • [KEY] string required

    The key to write to

  • [VALUE] string

    The value to write

  • --binding string

    The binding name to the namespace to write to

  • --namespace-id string

    The id of the namespace to write to

  • --preview boolean

    Interact with a preview namespace

  • --ttl number

    Time for which the entries should be visible

  • --expiration number

    Time since the UNIX epoch after which the entry expires

  • --metadata string

    Arbitrary JSON that is associated with a key

  • --path string

    Read value from the file at a given path

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv key list

Terminal window
npx wrangler kv key list
  • --binding string

    The binding name to the namespace to list

  • --namespace-id string

    The id of the namespace to list

  • --preview boolean default: false

    Interact with a preview namespace

  • --prefix string

    A prefix to filter listed keys

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv key get

Terminal window
npx wrangler kv key get [KEY]
  • [KEY] string required

    The key value to get.

  • --binding string

    The binding name to the namespace to get from

  • --namespace-id string

    The id of the namespace to get from

  • --preview boolean default: false

    Interact with a preview namespace

  • --text boolean default: false

    Decode the returned value as a utf8 string

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv key delete

Terminal window
npx wrangler kv key delete [KEY]
  • [KEY] string required

    The key value to delete.

  • --binding string

    The binding name to the namespace to delete from

  • --namespace-id string

    The id of the namespace to delete from

  • --preview boolean

    Interact with a preview namespace

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv bulk

Manage multiple key-value pairs within a Workers KV namespace in batches.

kv bulk get

Terminal window
npx wrangler kv bulk get [FILENAME]
  • [FILENAME] string required

    The file containing the keys to get

  • --binding string

    The binding name to the namespace to get from

  • --namespace-id string

    The id of the namespace to get from

  • --preview boolean

    Interact with a preview namespace

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv bulk put

Terminal window
npx wrangler kv bulk put [FILENAME]
  • [FILENAME] string required

    The file containing the key/value pairs to write

  • --binding string

    The binding name to the namespace to write to

  • --namespace-id string

    The id of the namespace to write to

  • --preview boolean

    Interact with a preview namespace

  • --ttl number

    Time for which the entries should be visible

  • --expiration number

    Time since the UNIX epoch after which the entry expires

  • --metadata string

    Arbitrary JSON that is associated with a key

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

kv bulk delete

Terminal window
npx wrangler kv bulk delete [FILENAME]
  • [FILENAME] string required

    The file containing the keys to delete

  • --binding string

    The binding name to the namespace to delete from

  • --namespace-id string

    The id of the namespace to delete from

  • --preview boolean

    Interact with a preview namespace

  • --force boolean alias: --f

    Do not ask for confirmation before deleting

  • --local boolean

    Interact with local storage

  • --remote boolean

    Interact with remote storage

  • --persist-to string

    Directory for local persistence

Global flags

The following global flags work on every command:

  • --help boolean
    • Show help.
  • --config string (not supported by Pages)
  • --cwd string
    • Run as if Wrangler was started in the specified directory instead of the current working directory.

Deprecations

Below are deprecations to Wrangler commands for Workers KV.

kv:... syntax deprecation

Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax.

The kv:... syntax is deprecated in versions 3.60.0 and beyond and will be removed in a future major version.

For example, commands using the kv ... syntax look as such:

Terminal window
wrangler kv namespace list
wrangler kv key get <KEY>
wrangler kv bulk put <FILENAME>

The same commands using the kv:... syntax look as such:

Terminal window
wrangler kv:namespace list
wrangler kv:key get <KEY>
wrangler kv:bulk put <FILENAME>