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 Wrangler file.
wrangler d1 create <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the new D1 database.
--locationstring optional- Provide an optional location hint for your database leader.
- Available options include
weur(Western Europe),eeur(Eastern Europe),apac(Asia Pacific),oc(Oceania),wnam(Western North America), andenam(Eastern North America).
Get information about a D1 database, including the current database size and state.
wrangler d1 info <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to get information about.
--jsonboolean optional- Return output as JSON rather than a table.
List all D1 databases in your account.
wrangler d1 list [OPTIONS]--jsonboolean optional- Return output as JSON rather than a table.
Delete a D1 database.
wrangler d1 delete <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to delete.
-y, --skip-confirmationboolean optional- Skip deletion confirmation prompt.
Execute a query on a D1 database.
wrangler d1 execute <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--commandstring optional- The SQL query you wish to execute.
--filestring optional- Path to the SQL file you wish to execute.
-y, --yesboolean optional- Answer
yesto any prompts.
- Answer
--localboolean (default: true) optional- Execute commands/files against a local database for use with wrangler dev.
--remoteboolean (default: false) optional- Execute commands/files against a remote D1 database for use with wrangler dev --remote.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--jsonboolean optional- Return output as JSON rather than a table.
--previewboolean optional- Execute commands/files against a preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Execute commands/files against a preview D1 database (as defined by
Export a D1 database or table's schema and/or content to a .sql file.
wrangler d1 export <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to export.
--localboolean (default: true) optional- Export from a local database for use with wrangler dev.
--remoteboolean (default: false) optional- Export from a remote D1 database for use with wrangler dev --remote.
--outputstring required- Path to the SQL file for your export.
--tablestring optional- The name of the table within a D1 database to export.
--no-databoolean (default: false) optional- Controls whether export SQL file contains database data. Note that
--no-data=trueis not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database data. Note that
--no-schemaboolean (default: false) optional- Controls whether export SQL file contains database schema. Note that
--no-schema=trueis not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database schema. Note that
Restore a database to a specific point-in-time using Time Travel.
wrangler d1 time-travel restore <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--bookmarkstring optional- A D1 bookmark representing the state of a database at a specific point in time.
--timestampstring optional- A UNIX timestamp or JavaScript date-time
stringwithin the last 30 days.
- A UNIX timestamp or JavaScript date-time
--jsonboolean optional- Return output as JSON rather than a table.
Inspect the current state of a database for a specific point-in-time using Time Travel.
wrangler d1 time-travel info <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--timestampstring optional- A UNIX timestamp or JavaScript date-time
stringwithin the last 30 days.
- A UNIX timestamp or JavaScript date-time
--jsonbboolean optional- Return output as JSON rather than a table.
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 below.
wrangler d1 migrations create <DATABASE_NAME> <MIGRATION_NAME>DATABASE_NAMEstring required- The name of the D1 database you wish to create a migration for.
MIGRATION_NAMEstring required- A descriptive name for the migration you wish to create.
View a list of unapplied migration files.
wrangler d1 migrations list <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database you wish to list unapplied migrations for.
--localboolean optional- Show the list of unapplied migration files on your locally persisted D1 database.
--remoteboolean (default: false) optional- Show the list of unapplied migration files on your remote D1 database.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--previewboolean optional- Show the list of unapplied migration files on your preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Show the list of unapplied migration files on your preview D1 database (as defined by
Apply any unapplied migrations.
This command will prompt you to confirm the migrations you are about to apply. Confirm that you would like to proceed. After, 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.
wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database you wish to apply your migrations on.
--envstring optional- Specify which environment configuration to use for D1 binding
--localboolean (default: true) optional- Execute any unapplied migrations on your locally persisted D1 database.
--remoteboolean (default: false) optional- Execute any unapplied migrations on your remote D1 database.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--previewboolean optional- Execute any unapplied migrations on your preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Execute any unapplied migrations on your preview D1 database (as defined by
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Returns statistics about your queries.
npx wrangler d1 insights <database_name> --<option>For more information, see Query insights.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark