Wrangler commands
D1 Wrangler commands use REST APIs to interact with the control plane. This page lists the Wrangler commands for D1.
Creates a new D1 database, and provides the binding and UUID that you will put in your config file
This command acts on remote D1 Databases.
npx wrangler d1 create [NAME]pnpm wrangler d1 create [NAME]yarn wrangler d1 create [NAME]-
[NAME]string requiredThe name of the new D1 database
-
--locationstringA hint for the primary location of the new DB. Options: weur: Western Europe eeur: Eastern Europe apac: Asia Pacific oc: Oceania wnam: Western North America enam: Eastern North America
-
--jurisdictionstringThe location to restrict the D1 database to run and store data within to comply with local regulations. Note that if jurisdictions are set, the location hint is ignored. Options: eu: The European Union fedramp: FedRAMP-compliant data centers
-
--use-remotebooleanUse a remote binding when adding the newly created resource to your config
-
--update-configbooleanAutomatically update your config file with the newly added resource
-
--bindingstringThe binding name of this resource in your Worker
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Get information about a D1 database, including the current database size and state
This command acts on remote D1 Databases.
npx wrangler d1 info [NAME]pnpm wrangler d1 info [NAME]yarn wrangler d1 info [NAME]-
[NAME]string requiredThe name of the DB
-
--jsonboolean default: falseReturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List all D1 databases in your account
This command acts on remote D1 Databases.
npx wrangler d1 listpnpm wrangler d1 listyarn wrangler d1 list-
--jsonboolean default: falseReturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Delete a D1 database
This command acts on remote D1 Databases.
npx wrangler d1 delete [NAME]pnpm wrangler d1 delete [NAME]yarn wrangler d1 delete [NAME]-
[NAME]string requiredThe name or binding of the DB
-
--skip-confirmationboolean alias: --y default: falseSkip confirmation
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Execute a command or SQL file
You must provide either --command or --file for this command to run successfully.
npx wrangler d1 execute [DATABASE]pnpm wrangler d1 execute [DATABASE]yarn wrangler d1 execute [DATABASE]-
[DATABASE]string requiredThe name or binding of the DB
-
--commandstringThe SQL query you wish to execute, or multiple queries separated by ';'
-
--filestringA .sql file to ingest
-
--yesboolean alias: --yAnswer "yes" to any prompts
-
--localbooleanExecute commands/files against a local DB for use with wrangler dev
-
--remotebooleanExecute commands/files against a remote D1 database for use with remote bindings or your deployed Worker
-
--persist-tostringSpecify directory to use for local persistence (for use with --local)
-
--jsonboolean default: falseReturn output as clean JSON
-
--previewboolean default: falseExecute commands/files against a preview D1 database
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Export the contents or schema of your database as a .sql file
npx wrangler d1 export [NAME]pnpm wrangler d1 export [NAME]yarn wrangler d1 export [NAME]-
[NAME]string requiredThe name of the D1 database to export
-
--localbooleanExport from your local DB you use with wrangler dev
-
--remotebooleanExport from a remote D1 database
-
--outputstring requiredPath to the SQL file for your export
-
--tablestringSpecify which tables to include in export
-
--no-schemabooleanOnly output table contents, not the DB schema
-
--no-databooleanOnly output table schema, not the contents of the DBs themselves
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Retrieve information about a database at a specific point-in-time using Time Travel
This command acts on remote D1 Databases.
For more information about Time Travel, see https://developers.cloudflare.com/d1/reference/time-travel/
npx wrangler d1 time-travel info [DATABASE]pnpm wrangler d1 time-travel info [DATABASE]yarn wrangler d1 time-travel info [DATABASE]-
[DATABASE]string requiredThe name or binding of the DB
-
--timestampstringAccepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for
-
--jsonboolean default: falseReturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Restore a database back to a specific point-in-time
This command acts on remote D1 Databases.
For more information about Time Travel, see https://developers.cloudflare.com/d1/reference/time-travel/
npx wrangler d1 time-travel restore [DATABASE]pnpm wrangler d1 time-travel restore [DATABASE]yarn wrangler d1 time-travel restore [DATABASE]-
[DATABASE]string requiredThe name or binding of the DB
-
--bookmarkstringBookmark to use for time travel
-
--timestampstringAccepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for (within the last 30 days)
-
--jsonboolean default: falseReturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Create a new migration
This will generate a new versioned file inside the 'migrations' folder. Name your migration file as a description of your change. This will make it easier for you to find your migration in the 'migrations' folder. An example filename looks like:
0000_create_user_table.sql
The filename will include a version number and the migration name you specify.
npx wrangler d1 migrations create [DATABASE] [MESSAGE]pnpm wrangler d1 migrations create [DATABASE] [MESSAGE]yarn wrangler d1 migrations create [DATABASE] [MESSAGE]-
[DATABASE]string requiredThe name or binding of the DB
-
[MESSAGE]string requiredThe Migration message
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
View a list of unapplied migration files
npx wrangler d1 migrations list [DATABASE]pnpm wrangler d1 migrations list [DATABASE]yarn wrangler d1 migrations list [DATABASE]-
[DATABASE]string requiredThe name or binding of the DB
-
--localbooleanCheck migrations against a local DB for use with wrangler dev
-
--remotebooleanCheck migrations against a remote DB for use with wrangler dev --remote
-
--previewboolean default: falseCheck migrations against a preview D1 DB
-
--persist-tostringSpecify directory to use for local persistence (you must use --local with this flag)
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Apply any unapplied D1 migrations
This command will prompt you to confirm the migrations you are about to apply. Confirm that you would like to proceed. After applying, a backup will be captured.
The progress of each migration will be printed in the console.
When running the apply command in a CI/CD environment or another non-interactive command line, the confirmation step will be skipped, but the backup will still be captured.
If applying a migration results in an error, this migration will be rolled back, and the previous successful migration will remain applied.
npx wrangler d1 migrations apply [DATABASE]pnpm wrangler d1 migrations apply [DATABASE]yarn wrangler d1 migrations apply [DATABASE]-
[DATABASE]string requiredThe name or binding of the DB
-
--localbooleanExecute commands/files against a local DB for use with wrangler dev
-
--remotebooleanExecute commands/files against a remote DB for use with wrangler dev --remote
-
--previewboolean default: falseExecute commands/files against a preview D1 DB
-
--persist-tostringSpecify directory to use for local persistence (you must use --local with this flag)
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Experimental
Get information about the queries run on a D1 database
This command acts on remote D1 Databases.
npx wrangler d1 insights [NAME]pnpm wrangler d1 insights [NAME]yarn wrangler d1 insights [NAME]-
[NAME]string requiredThe name of the DB
-
--timePeriodstring default: 1dFetch data from now to the provided time period
-
--sort-typestring default: sumChoose the operation you want to sort insights by
-
--sort-bystring default: timeChoose the field you want to sort insights by
-
--sort-directionstring default: DESCChoose a sort direction
-
--limitnumber default: 5fetch insights about the first X queries
-
--jsonboolean default: falsereturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2026 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-