Movatterモバイル変換


[0]ホーム

URL:


Skip to content

CLI commands for n8n#

n8n includes a CLI (command line interface), allowing you to perform actions using the CLI rather than the n8n editor. These include starting workflows, and exporting and importing workflows and credentials.

Running CLI commands#

You can use CLI commands with self-hosted n8n. Depending on how you choose to install n8n, there are differences in how to run the commands:

  • npm: then8n command is directly available. The documentation uses this in the examples below.
  • Docker: then8n command is available within your Docker container:

    1
    dockerexec-unode-it<n8n-container-name><n8n-cli-command>

Start a workflow#

You can start workflows directly using the CLI.

Execute a saved workflow by its ID:

1
n8nexecute--id<ID>

Change the active status of a workflow#

You can change the active status of a workflow using the CLI.

Restart required

These commands operate on your n8n database. If you execute them while n8n is running, the changes don't take effect until you restart n8n.

Set the active status of a workflow by its ID to false:

1
n8nupdate:workflow--id=<ID>--active=false

Set the active status of a workflow by its ID to true:

1
n8nupdate:workflow--id=<ID>--active=true

Set the active status to false for all the workflows:

1
n8nupdate:workflow--all--active=false

Set the active status to true for all the workflows:

1
n8nupdate:workflow--all--active=true

Export workflows and credentials#

You can export your workflows and credentials from n8n using the CLI.

Command flags:

FlagDescription
--helpHelp prompt.
--allExports all workflows/credentials.
--backupSets --all --pretty --separate for backups. You can optionally set --output.
--idThe ID of the workflow to export.
--outputOutputs file name or directory if using separate files.
--prettyFormats the output in an easier to read fashion.
--separateExports one file per workflow (useful for versioning). Must set a directory using --output.
--decryptedExports the credentials in a plain text format.

Workflows#

Export all your workflows to the standard output (terminal):

1
n8nexport:workflow--all

Export a workflow by its ID and specify the output file name:

1
n8nexport:workflow--id=<ID>--output=file.json

Export all workflows to a specific directory in a single file:

1
n8nexport:workflow--all--output=backups/latest/file.json

Export all the workflows to a specific directory using the--backup flag (details above):

1
n8nexport:workflow--backup--output=backups/latest/

Credentials#

Export all your credentials to the standard output (terminal):

1
n8nexport:credentials--all

Export credentials by their ID and specify the output file name:

1
n8nexport:credentials--id=<ID>--output=file.json

Export all credentials to a specific directory in a single file:

1
n8nexport:credentials--all--output=backups/latest/file.json

Export all the credentials to a specific directory using the--backup flag (details above):

1
n8nexport:credentials--backup--output=backups/latest/

Export all the credentials in plain text format. You can use this to migrate from one installation to another that has a different secret key in the configuration file.

Sensitive information

All sensitive information is visible in the files.

1
n8nexport:credentials--all--decrypted--output=backups/decrypted.json

Import workflows and credentials#

You can import your workflows and credentials from n8n using the CLI.

Update the IDs

When exporting workflows and credentials, n8n also exports their IDs. If you have workflows and credentials with the same IDs in your existing database, they will be overwritten. To avoid this, delete or change the IDs before importing.

Available flags:

FlagDescription
--helpHelp prompt.
--inputInput file name or directory if you use --separate.
--projectIdImport the workflow or credential to the specified project. Can't be used with--userId.
--separateImports*.json files from directory provided by --input.
--userIdImport the workflow or credential to the specified user. Can't be used with--projectId.

Migrating to SQLite

n8n limits workflow and credential names to 128 characters, but SQLite doesn't enforce size limits.

This might result in errors likeData too long for column name during the import process.

In this case, you can edit the names from the n8n interface and export again, or edit the JSON file directly before importing.

Workflows#

Import workflows from a specific file:

1
n8nimport:workflow--input=file.json

Import all the workflow files as JSON from the specified directory:

1
n8nimport:workflow--separate--input=backups/latest/

Credentials#

Import credentials from a specific file:

1
n8nimport:credentials--input=file.json

Import all the credentials files as JSON from the specified directory:

1
n8nimport:credentials--separate--input=backups/latest/

License#

Clear#

Clear your existing license from n8n's database and reset n8n to default features:

1
n8nlicense:clear

If your license includesfloating entitlements, running this command will also attempt to release them back to the pool, making them available for other instances.

Info#

Display information about the existing license:

1
n8nlicense:info

User management#

You can reset user management using the n8n CLI. This returns user management to its pre-setup state. It removes all user accounts.

Use this if you forget your password, and don't have SMTP set up to do password resets by email.

1
n8nuser-management:reset

Disable MFA for a user#

If a user loses their recovery codes you can disable MFA for a user with this command. The user will then be able to log back in to set up MFA again.

1
n8nmfa:disable--email=johndoe@example.com

Disable LDAP#

You can reset the LDAP settings using the command below.

1
n8nldap:reset

Uninstall community nodes and credentials#

You can managecommunity nodes using the n8n CLI. For now, you can only uninstall community nodes and credentials, which is useful if a community node causes instability.

Command flags:

FlagDescription
--helpShow CLI help.
--credentialThe credential type. Get this value by visiting the node's<NODE>.credential.ts file and getting the value ofname.
--packagePackage name of the community node.
--uninstallUninstalls the node.
--userIdThe ID of the user who owns the credential. On self-hosted, query the database. On cloud, query the API with your API key.

Nodes#

Uninstall a community node by package name:

1
n8ncommunity-node--uninstall--package<COMMUNITY_NODE_NAME>

For example, to uninstall theEvolution API community node, type:

1
n8ncommunity-node--uninstall--packagen8n-nodes-evolution-api

Credentials#

Uninstall a community node credential:

1
n8ncommunity-node--uninstall--credential<CREDENTIAL_TYPE>--userId<ID>

For example, to uninstall theEvolution API community node credential, visit therepository and navigate to thecredentials.ts file to find thename:

1
n8ncommunity-node--uninstall--credentialevolutionApi--userId1234

Security audit#

You can run asecurity audit on your n8n instance, to detect common security issues.

1
n8naudit

[8]ページ先頭

©2009-2025 Movatter.jp