Command Line Interface (CLI)
Strapi comes with a full featured Command Line Interface (CLI) which lets you scaffold and manage your project in seconds. The CLI works with both the yarn and npm package managers.
Interactive commands such as strapi admin:create-user don't display prompts with npm. Please consider using the yarn package manager.
It is recommended to install Strapi locally only, which requires prefixing all of the following strapi commands with the package manager used for the project setup (e.g npm run strapi help or yarn strapi help) or a dedicated node package executor (e.g. npx strapi help).
To pass options with npm use the syntax: npm run strapi <command> -- --<option>.
To pass options with yarn use the syntax: yarn strapi <command> --<option>
ℹ️ Strapi v4 CLI commands removed from Strapi 5:
The strapi install, strapi uninstall, strapi new, and strapi watch-admin commands from Strapi v4 have been removed in Strapi 5:
| Strapi v4 command | Strapi 5 equivalent |
|---|---|
strapi install [plugin] | Use the npx command corresponding to the plugin (found on the Marketplace, see Marketplace) |
strapi new | Use the equivalent yarn or npx command to create a new Strapi project (see CLI installation guide) |
strapi watch-admin | yarn develop or npm run develop always starts the Strapi server in "watch-admin" mode. To disable this in Strapi 5, run yarn develop --no-watch-admin or npm run develop --no-watch-admin. |
strapi develop
Alias: dev
Start a Strapi application with auto-reloading enabled.
Strapi modifies/creates files at runtime and needs to restart when new files are created. To achieve this, strapi develop adds a file watcher and restarts the application when necessary.
Strapi also adds middlewares to support HMR (Hot Module Replacement) for the administration panel. This allows you to customize the administration panel without having to restart the application or run a separate server.
strapi develop
options: [--bundler | --open | --no-watch-admin | --no-build-admin | --polling | --debug | --silent]
- strapi develop --bundler [bundler]
Selects the bundler for the admin panel build (viteorwebpack). - strapi develop --open
Starts your application with auto-reloading enabled & open your default browser with the administration panel running. - strapi develop --no-watch-admin
Prevents the server from auto-reload when changes are made to the admin panel code. - strapi develop --no-build-admin
Prevents the admin panel from being built when--no-watch-adminis enabled. - strapi develop --polling
Watches for file changes in network directories. - strapi develop --debug
Enables debugging mode with verbose logs. - strapi develop --silent
Suppresses logs.
You should never use this command to run a Strapi application in production.
strapi start
Start a Strapi application with auto-reloading disabled.
This command is to run a Strapi application without restarts and file writes, primarily for use in production.
Certain features such as the Content-type Builder are disabled in the strapi start mode because they require application restarts. The start command can be prefaced with environment variables to customize the application start.
strapi build
Builds your admin panel.
strapi build
| Option | Type | Description |
|---|---|---|
-d, --debug | - | Enable debugging mode with verbose logs (default: false) |
--minify | - | Minify the output (default: true) |
--no-optimization | - | [DEPRECATED]: use minify instead |
--silent | - | Don't log anything (default: false) |
--sourcemaps | - | Produce sourcemaps (default: false) |
--stats | - | Print build statistics to the console (default: false) |
strapi login
Logs in to Strapi Cloud (see Cloud CLI documentation).
strapi logout
Logs out from Strapi Cloud (see Cloud CLI documentation).
strapi deploy
Deploys to Strapi Cloud (see Cloud CLI documentation).
strapi export
Exports your project data. The default settings create a .tar file, compressed using gzip and encrypted using aes-128-ecb.
strapi export
The archive contains folders such as configuration, entities, links, and schemas with data stored in JSON lines files. Use --no-encrypt --no-compress to generate a readable .tar that can be inspected or converted to other formats.
The exported file is automatically named using the format export_YYYYMMDDHHMMSS with the current date and timestamp. Alternately, you can specify the filename using the -f or --file flag. The following table provides all of the available options as command line flags:
| Option | Type | Description |
|---|---|---|
--no-encrypt | - | Disables file encryption and disables the key option. |
--no-compress | - | Disables file compression. |
-k, --key | string | Passes the encryption key as part of the export command. The --key option can't be combined with --no-encrypt. |
-f, --file | string | Specifies the export filename (tar) or output directory path (dir). Do not include a file extension for tar exports. |
--format | string | Export format: tar (default) or dir. Directory exports require --no-encrypt. |
--exclude | string | Exclude data using comma-separated data types. The available types are: content, files, and config. |
--only | string | Include only these data. The available types are: content, files, and config. |
-h, --help | - | Displays help for the strapi export command. |
Examples
Export data with a custom filename (myData.tar.gz.enc):
strapi export -f myData
Export data without encryption:
strapi export --no-encrypt
Export data as an unpacked directory:
strapi export --format dir --no-encrypt -f my-export