n8n via CLI: Import/Export, User Reset
How to export and import n8n workflows via CLI, and reset a user's password from the command line if you're locked out.
Anyone who self-hosts n8n eventually reaches the point where workflows need to be backed up, transferred to another instance, or a locked-out user account needs to be reset. For all three tasks, n8n provides its own CLI commands that run directly on the server and work without a functioning web interface. This article shows the most important commands for export, import, and the emergency password reset, as described in the official n8n documentation. As of: July 2026.
Exporting workflows via CLI
The export:workflow command exports workflows from the n8n database into JSON files. Without additional arguments it applies to individual workflows, but with the right flags the export can be extended to the entire set or prepared directly for a backup.
- --all: Exports all workflows of the instance instead of just a single one.
- --id=<ID>: Exports only the workflow with the specified ID.
- --output or -o: Sets the target file or, for multiple workflows, the target directory.
- --backup: Automatically sets --all, --pretty, and --separate for a complete, readable backup.
- --separate: Writes each workflow as its own file, requires a directory when used with --output.
- --pretty: Formats the JSON output in a readable way instead of compactly.
- --published: Exports the published version of a workflow instead of the current draft.
- --version=<VERSION_ID>: Exports a specific historical version of a workflow.
For regular backups, the combination export:workflow --backup --output=backups/latest/ is especially suitable, and can be scheduled well as a daily or weekly task in a cron job.
Importing workflows via CLI
The counterpart is import:workflow. It reads previously exported JSON files and writes them back into the database of the target instance, for example during a server move or a recovery after an outage.
- --input: Path to the input file or, together with --separate, to a directory with multiple files.
- --separate: Imports all JSON files from a directory instead of just a single file.
- --projectId: Assigns the imported workflows to a specific project.
- --userId: Assigns the imported workflows to a specific user.
- --activeState: Controls whether imported workflows are activated, false by default, or fromJson in multi-main operation.
- --skipMigrationChecks: Skips validation checks during import.
Important: Workflows with an ID that already exists in the target database are overwritten during import, not duplicated. Before an import on a production instance, it is therefore always worthwhile to first export the existing workflows as a backup.
Emergency: Password reset via CLI when locked out
If access to an n8n account is missing because a password was forgotten and no SMTP server is set up for the regular reset by email, the command user-management:reset helps, according to the n8n documentation. It resets user management to the state before initial setup and removes all existing user accounts. The next time the web interface is opened, n8n asks again for the setup of a new owner account, similar to a fresh installation.
The command is deliberately radical: it deletes all user accounts of the instance, not just the affected one. Roles, permissions, and project assignments must be reassigned afterward. Workflows, credentials, and the execution history remain unaffected by this according to the documentation, since the command only resets user management.
For the narrower case that someone can no longer use two-factor authentication, for example because the recovery codes have been lost, the less drastic command mfa:disable --email=<email-address> is sufficient. It disables MFA for exactly that one account, so the person can log in again normally and set up two-factor authentication anew.
Other CLI commands for everyday operations
- export:credentials and import:credentials: Back up and transfer credentials; with --decrypted all sensitive values end up in plain text in the file, which should be handled with corresponding caution.
- audit: Checks the instance for common security issues.
- license:info and license:clear: Show the current license or reset it to the default feature set.
- n8n --help: Lists all available commands of the installed n8n version, since the feature set can differ by version.
The CLI commands run directly on the server and require corresponding access, for example via SSH or docker exec. Anyone running n8n with a provider without shell access generally cannot use them and depends on the provider's support. For companies that self-host n8n and rely on reliable backups and a documented emergency plan in everyday operations, NordFlux supports the n8n setup and operation with a setup where you retain control over data and access yourself.
Frequently asked questions about n8n CLI import/export
How do I automatically back up all n8n workflows?
With the command export:workflow --backup --output=<directory> all workflows can be backed up in a readable, split form. The command works well as a daily cron job on the server, supplemented with a copy of the target directory to a second storage location.
Are workflows and credentials also deleted with user-management:reset?
No. According to the n8n documentation, the command exclusively resets user management and removes all user accounts. Workflows, credentials, and the execution history are retained, but must be reassigned to a new owner account after the reset.
Can I export individual workflows instead of the entire instance?
Yes. With export:workflow --id=<ID> --output=file.json a single workflow can be exported specifically, without touching the rest of the set.
What happens if an imported workflow ID already exists?
The existing workflow with the same ID is overwritten during import, not created as a copy. It is therefore recommended to make a current export as a fallback before every import on a running instance, see the n8n documentation on the command line and the documentation on user management.
NordFlux UG (haftungsbeschränkt)
NordFlux builds digital employees for organisations: automations and AI agents that take over repetitive work. You stay in control.
Concrete questions about automation or AI?
In a free initial analysis we discuss your case directly. No strings attached.