Skip to content

KV CLI commands

kv namespaces

Manage Workers KV namespaces.

kv namespaces create

Creates a Workers KV namespace in the specified account with the given title. Returns 400 if the account already owns a namespace with that title; an existing namespace must be explicitly deleted before it can be replaced. An optional jurisdiction restricts where data is durably stored and can only be set at creation time.

cf kv namespaces create [options]
  • --jurisdiction"eu" | "fedramp" | "us"

    Specify the jurisdiction to restrict the KV namespace to durably store data within. Can only be set at namespace creation time.

  • --namespace-mode"instant"

    The mode of the Workers KV namespace. Specify instant when creating a namespace to create a KV Instant namespace. Omit this field when creating a namespace to create a classic namespace. Currently, instant is the only supported explicit value.

  • --titlestring required

    Human-readable string name for a Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --bodystring

    Raw JSON request body (bypasses individual flags)

To restrict where a namespace durably stores data, specify --jurisdiction when creating it. Refer to Data location for supported jurisdictions.

KV Instant namespaces

To create a Workers KV Instant namespace with cf, pass --namespace-mode instant. This example creates a namespace named APP_CONFIG for small, infrequently updated configuration:

cf kv namespaces create --title APP_CONFIG --namespace-mode instant

kv namespaces list

Lists Workers KV namespaces owned by the specified account. Use page and per_page to select a page of results, and order and direction to control sorting.

cf kv namespaces list [options]
  • --pagenumber

    Page number of paginated results.

  • --per-pagenumber

    Maximum number of results per page.

  • --order"id" | "title"

    Namespace field to sort by (id or title).

  • --direction"asc" | "desc"

    Sort namespaces in ascending (asc) or descending (desc) order.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

kv namespaces get

Returns the Workers KV namespace for the specified account and namespace ID.

cf kv namespaces get <namespace-id>
  • <NAMESPACE-ID>string required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

kv namespaces update

Changes the title of the specified Workers KV namespace and returns the updated namespace. The namespace ID and stored key-value pairs are unchanged.

cf kv namespaces update <namespace-id> [options]
  • <NAMESPACE-ID>string required

    ID of the Workers KV namespace.

  • --titlestring required

    Human-readable string name for a Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --bodystring

    Raw JSON request body (bypasses individual flags)

kv namespaces delete

Deletes the specified Workers KV namespace and its stored key-value pairs from the account.

cf kv namespaces delete <namespace-id>
  • <NAMESPACE-ID>string required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --forceboolean default: false

    Skip confirmation (useful in scripts and CI)

kv keys

Manage single and bulk key-value pairs within a Workers KV namespace. Pass --local to target local development state, or pass @<FILE_PATH> to --body to read a JSON file for bulk operations.

kv keys put

Writes a value under the specified key in the Workers KV namespace, creating the key-value pair or replacing its existing value, expiration, and metadata. Send the value as an application/octet-stream request body, or use multipart/form-data with a value part and an optional JSON metadata part. Use URL-encoding for special characters (for example, :, !, %) in the key name when constructing the request URL. If neither expiration nor expiration_ttl is specified, the key-value pair will not expire. If both are set, expiration_ttl takes precedence.

cf kv keys put <key-name> [options]
  • <KEY-NAME>string required

    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --expirationnumber

    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.

  • --expiration-ttlnumber

    Number of seconds until the key expires. Must be at least 60. Takes precedence over expiration when both are specified.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --bodystring

    Raw JSON request body (bypasses individual flags)

  • --filestring

    Path to a file to upload as the request body

  • --metadatastring

    Associates arbitrary JSON data with a key/value pair.

kv keys list

Lists key names in the specified Workers KV namespace, with expiration times and metadata when present. Use prefix to filter names and cursor to request the next page. Values are not included.

cf kv keys list [options]
  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --limitnumber

    Maximum number of keys to return in one response. Pass result_info.cursor from the response as cursor to request the next page.

  • --prefixstring

    Filters returned keys by a name prefix. Exact matches and any key names that begin with the prefix will be returned.

  • --cursorstring

    Opaque pagination token from result_info.cursor in the previous response. Pass it unchanged to request the next page of keys.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

kv keys get

Returns the value stored under the specified key in the Workers KV namespace as raw bytes. Use URL-encoding for special characters (for example, :, !, %) in the key name when constructing the request URL. If the key-value pair expires, the expiration response header contains its expiration time in seconds since the UNIX epoch.

cf kv keys get <key-name> [options]
  • <KEY-NAME>string required

    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --textboolean default: false

    Decode the response body as UTF-8 text instead of writing raw bytes

kv keys delete

Deletes the specified key and its value from the Workers KV namespace. Use URL-encoding for special characters (for example, :, !, %) in the key name when constructing the request URL.

cf kv keys delete <key-name> [options]
  • <KEY-NAME>string required

    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --forceboolean default: false

    Skip confirmation (useful in scripts and CI)

kv keys bulk-get

Retrieves the text-based values of up to 100 keys from the specified Workers KV namespace. The result maps each requested key to its value. Set type to json to parse JSON values instead of returning strings, and set withMetadata to true to include metadata with each value. Binary values are not supported by this operation.

cf kv keys bulk-get [options]
  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --keysstring required

    Array of keys to retrieve (maximum of 100).

  • --type"text" | "json" default: text

    Return values as strings with text, or parse stored JSON values with json.

  • --with-metadataboolean default: false

    Whether to include metadata in the response.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --bodystring

    Raw JSON request body (bypasses individual flags)

kv keys bulk-put

Writes up to 10,000 key-value pairs to the specified Workers KV namespace from a JSON array, with optional metadata and expiration settings for each pair. Existing values and expirations are overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will not expire. If both are set, expiration_ttl takes precedence. The entire request must be 100 megabytes or less. The result reports the number of successful writes and any keys that failed and should be retried.

cf kv keys bulk-put [options]
  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --bodystring

    Raw JSON request body (bypasses individual flags)

kv keys bulk-delete

Deletes up to 10,000 key-value pairs from the specified Workers KV namespace. Send a JSON array of the key names to delete. The result reports the number of successful deletions and any keys that failed and should be retried.

cf kv keys bulk-delete [options]
  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

  • --forceboolean default: false

    Skip confirmation (useful in scripts and CI)

  • --bodystring

    Raw JSON request body (bypasses individual flags)

kv metadata

Read key metadata without fetching the key's value.

kv metadata get

Returns the JSON metadata associated with the specified key in the Workers KV namespace, without retrieving its value. Use URL-encoding for special characters (for example, :, !, %) in the key name when constructing the request URL.

cf kv metadata get <key-name> [options]
  • <KEY-NAME>string required

    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

  • --namespace-idstring required

    ID of the Workers KV namespace.

  • --dry-runboolean default: false

    Validate and show what would happen without executing

kv namespace

Manage Workers KV namespaces.

kv namespace create

Create a new namespace

npx wrangler kv namespace create <NAMESPACE>
  • <NAMESPACE>string required

    The name of the new namespace

  • --previewboolean

    Interact with a preview namespace

  • --jurisdictionstring

    The jurisdiction where the new namespace will be created (e.g. "us", "eu", "fedramp")

  • --experimental-modestring alias: --x-mode

    The storage mode for the new namespace. Instant mode offers lower-latency reads and faster global updates [private beta]. Cannot be combined with --jurisdiction.

  • --use-remoteboolean

    Use a remote binding when adding the newly created resource to your config

  • --update-configboolean

    Automatically update your config file with the newly added resource

  • --bindingstring

    The binding name of this resource in your Worker

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

To restrict where a namespace durably stores data, specify --jurisdiction when creating it. Refer to Data location for supported jurisdictions.

KV Instant namespaces

To create a Workers KV Instant namespace, pass --experimental-mode instant. This example creates a namespace named APP_CONFIG for small, infrequently updated configuration:

npx wrangler@latest kv namespace create APP_CONFIG --experimental-mode instant

You can also use the --x-mode instant alias.

kv namespace list

Output a list of all KV namespaces associated with your account id

npx wrangler kv namespace list

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv namespace delete

Delete a given namespace.

npx wrangler kv namespace delete [NAMESPACE]
  • [NAMESPACE]string

    The name of the namespace to delete

  • --bindingstring

    The binding name to the namespace to delete from

  • --namespace-idstring

    The id of the namespace to delete

  • --previewboolean

    Interact with a preview namespace

  • --skip-confirmationboolean alias: --ydefault: false

    Skip confirmation

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv namespace rename

Rename a KV namespace

npx wrangler kv namespace rename [OLD-NAME] --new-name <NEW-NAME>
  • [OLD-NAME]string

    The current name of the namespace to rename

  • --namespace-idstring

    The id of the namespace to rename

  • --new-namestring required

    The new name for the namespace

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv key

Manage key-value pairs within a Workers KV namespace.

kv key put

Write a single key/value pair to the given namespace

npx wrangler kv key put <KEY> [VALUE]
  • <KEY>string required

    The key to write to

  • [VALUE]string

    The value to write

  • --pathstring

    Read value from the file at a given path

  • --bindingstring

    The binding name to the namespace to write to

  • --namespace-idstring

    The id of the namespace to write to

  • --previewboolean

    Interact with a preview namespace

  • --ttlnumber

    Time for which the entries should be visible

  • --expirationnumber

    Time since the UNIX epoch after which the entry expires

  • --metadatastring

    Arbitrary JSON that is associated with a key

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv key list

Output a list of all keys in a given namespace

npx wrangler kv key list
  • --bindingstring

    The binding name to the namespace to list

  • --namespace-idstring

    The id of the namespace to list

  • --previewboolean default: false

    Interact with a preview namespace

  • --prefixstring

    A prefix to filter listed keys

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv key get

Read a single value by key from the given namespace

npx wrangler kv key get <KEY>
  • <KEY>string required

    The key value to get.

  • --textboolean default: false

    Decode the returned value as a utf8 string

  • --bindingstring

    The binding name to the namespace to get from

  • --namespace-idstring

    The id of the namespace to get from

  • --previewboolean default: false

    Interact with a preview namespace

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv key delete

Remove a single key value pair from the given namespace

npx wrangler kv key delete <KEY>
  • <KEY>string required

    The key value to delete.

  • --bindingstring

    The binding name to the namespace to delete from

  • --namespace-idstring

    The id of the namespace to delete from

  • --previewboolean

    Interact with a preview namespace

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv bulk

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

kv bulk get

Gets multiple key-value pairs from a namespace

npx wrangler kv bulk get <FILENAME>
  • <FILENAME>string required

    The file containing the keys to get

  • --bindingstring

    The binding name to the namespace to get from

  • --namespace-idstring

    The id of the namespace to get from

  • --previewboolean default: false

    Interact with a preview namespace

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv bulk put

Upload multiple key-value pairs to a namespace

npx wrangler kv bulk put <FILENAME>
  • <FILENAME>string required

    The file containing the key/value pairs to write

  • --bindingstring

    The binding name to the namespace to write to

  • --namespace-idstring

    The id of the namespace to write to

  • --previewboolean

    Interact with a preview namespace

  • --ttlnumber

    Time for which the entries should be visible

  • --expirationnumber

    Time since the UNIX epoch after which the entry expires

  • --metadatastring

    Arbitrary JSON that is associated with a key

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

kv bulk delete

Delete multiple key-value pairs from a namespace

npx wrangler kv bulk delete <FILENAME>
  • <FILENAME>string required

    The file containing the keys to delete

  • --forceboolean alias: --f

    Do not ask for confirmation before deleting

  • --bindingstring

    The binding name to the namespace to delete from

  • --namespace-idstring

    The id of the namespace to delete from

  • --previewboolean

    Interact with a preview namespace

  • --localboolean

    Interact with local storage

  • --remoteboolean

    Interact with remote storage

  • --persist-tostring

    Directory for local persistence

Global flags

  • --vboolean alias: --version

    Show version number

  • --cwdstring

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --configstring alias: --c

    Path to Wrangler configuration file

  • --envstring alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-filestring

    Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files

  • --install-skillsboolean default: false

    Install Cloudflare skills for detected AI coding agents before running the command

  • --profilestring

    Use a specific auth profile

Deprecations

The following deprecations apply 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:

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

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

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

Was this helpful?