Skip to main content

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.

Caution

Interactive commands such as strapi admin:create-user don't display prompts with npm. Please consider using the yarn package manager.

Note

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 commandStrapi 5 equivalent
strapi install [plugin]Use the npx command corresponding to the plugin (found on the Marketplace, see Marketplace)
strapi newUse the equivalent yarn or npx command to create a new Strapi project (see CLI installation guide)
strapi watch-adminyarn 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 (vite or webpack).
  • 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-admin is 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.
Warning

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
OptionTypeDescription
-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:

OptionTypeDescription
--no-encrypt-Disables file encryption and disables the key option.
--no-compress-Disables file compression.
-k,
--key
stringPasses the encryption key as part of the export command.
The --key option can't be combined with --no-encrypt.
-f,
--file
stringSpecifies the export filename. Do not include a file extension.
--excludestringExclude data using comma-separated data types. The available types are: content, files, and config.
--onlystringInclude only these data. The available types are: content, files, and config.
-h,
--help
-Displays help for the strapi export command.

Examples

Examples of strapi export:
# export your data with the default options and the filename myData, which results in a file named myData.tar.gz.enc.
strapi export -f myData

# export your data without encryption.
strapi export --no-encrypt

strapi import

Imports data into your project. The imported data must originate from another Strapi application. You must pass the --file option to specify the filename and location for the import action.

strapi import

The command accepts archives generated by strapi export. Compression (.gz) and encryption (.enc) are detected from the filename, so providing a plain .tar is also valid.

OptionTypeDescription
-k, --keystringProvide the encryption key in the command instead of a subsequent prompt.
-f, --filestringPath and filename with extension for the data to be imported.
-h, --help-Display the strapi import help commands.

Examples

Example of strapi import:

# import your data with the default parameters and pass an encryption key:
strapi import -f your-filepath-and-filename --key my-key

strapi transfer

Transfers data between 2 Strapi instances. This command is primarily intended for use between a local instance and a remote instance or 2 remote instances. The transfer command requires a Transfer token, which is generated in the destination instance Admin panel. See the User Guide for detailed documentation on creating Transfer tokens.

Caution

The destination Strapi instance should be running with the start command and not the develop command.

OptionDescription
--to [destinationURL]Full URL of the /admin endpoint on the destination Strapi instance
(e.g. --to https://my-beautiful-strapi-website/admin)
--to-token [transferToken]Transfer token for the remote Strapi destination
--from [sourceURL]Full URL of the /admin endpoint of the remote Strapi instance to pull data from
(e.g., --from https://my-beautiful-strapi-website/admin)
‑‑from‑tokenTransfer token from the Strapi source instance.
--forceAutomatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively.
--excludeExclude data using comma-separated data types. The available types are: content, files, and config.
--onlyInclude only these data. The available types are: content, files, and config.
-h, --helpDisplays the commands for strapi transfer.
Caution

Either --to or --from is required, but it's not currently allowed to enter both or neither.

Example

strapi transfer --to http://example.com/admin --to-token my-transfer-token

strapi report

Prints out debug information useful for debugging and required when reporting an issue.

OptionDescription
-u, --uuidIncludes the project UUID
-d, --dependenciesIncludes project dependencies
--allLogs all the data

Examples

To include the project UUID and dependencies in the output:

strapi report --uuid --dependencies

To log everything, use the --all option:

strapi report --all

strapi configuration:dump