Learn how to export workflows from n8n using the web interface, CLI, or REST API for backup, sharing, and migration. Step-by-step guide included.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To export workflows from n8n, you can use the built-in export feature in the n8n web interface, command-line interface (CLI), or REST API. Exporting workflows allows you to back up your workflows, share them with others, or migrate them to a different n8n instance.
Step 1: Exporting Workflows via the Web Interface
The simplest way to export workflows from n8n is through the web interface. This method requires no technical knowledge and can be done in a few clicks.
Step 1.1: Log in to your n8n instance
Open your web browser and navigate to your n8n instance URL. This is typically something like:
http://localhost:5678
Or if you're using n8n cloud:
https://app.n8n.cloud
Enter your credentials to log in if required.
Step 1.2: Navigate to the Workflows page
Once logged in, you should see the main dashboard. Click on "Workflows" in the left sidebar to view all your workflows.
Step 1.3: Select the workflow to export
Find the workflow you want to export in the list. You can use the search function if you have many workflows.
Step 1.4: Export the workflow
Click on the three dots (⋮) menu next to the workflow you want to export. A dropdown menu will appear.
Select "Export" from this menu. This will open a dialog box with export options.
Step 1.5: Choose export options
In the export dialog, you can choose between different export formats:
For most backup and migration purposes, select "JSON" or "JSON (without credentials)".
Step 1.6: Complete the export
Click the "Export" button. Your browser will download the workflow as a JSON file. The file will typically be named after your workflow with a .json extension.
Step 2: Batch Exporting Multiple Workflows via the Web Interface
If you need to export multiple workflows at once, n8n provides a batch export feature.
Step 2.1: Go to the Workflows page
Navigate to the Workflows page as described in Step 1.2.
Step 2.2: Select multiple workflows
Use the checkboxes to the left of each workflow to select all the workflows you want to export.
Step 2.3: Use the batch actions menu
Once you've selected workflows, a batch actions menu appears at the top of the workflow list.
Click on the "Export" button in this batch actions menu.
Step 2.4: Choose export options and complete
Select your preferred export format (usually JSON) and click "Export". The browser will download a single JSON file containing all selected workflows.
Step 3: Exporting Workflows via the CLI
For more advanced users or for automation purposes, you can export workflows using the n8n Command Line Interface.
Step 3.1: Access the command line
Open a terminal or command prompt on the server where n8n is installed.
Step 3.2: Check if n8n is in your PATH
If you installed n8n globally with npm, the n8n command should be available. Test it by running:
n8n --version
If this doesn't work, you might need to navigate to your n8n installation directory or use npx:
npx n8n --version
Step 3.3: Export a specific workflow by ID
To export a specific workflow, you need to know its ID. You can find this in the URL when viewing a workflow in the web interface.
Use the following command to export a workflow by ID:
n8n export:workflow --id=YOUR_WORKFLOW_ID
Replace YOUR_WORKFLOW_ID with the actual ID of your workflow.
Step 3.4: Export a workflow to a specific file
By default, the exported workflow will be output to the console. To save it to a file, use:
n8n export:workflow --id=YOUR_WORKFLOW_ID --output=my-workflow.json
This will save the workflow to a file named "my-workflow.json" in the current directory.
Step 3.5: Export all workflows
To export all workflows at once, use:
n8n export:workflow --all --output=all-workflows.json
This will export all workflows to a single JSON file.
Step 3.6: Export workflows without credentials
For security reasons, you may want to export workflows without their credentials:
n8n export:workflow --id=YOUR_WORKFLOW_ID --decrypted --output=workflow-without-creds.json
The --decrypted flag removes credential data from the export.
Step 4: Exporting Workflows via the REST API
For integration with other systems or programmatic access, n8n provides a REST API for workflow export.
Step 4.1: Obtain API credentials
Before using the API, you need to have:
In n8n, go to Settings → API → API Keys to create an API key if you don't have one already.
Step 4.2: Use the GET endpoint to retrieve a workflow
To export a specific workflow by ID, make a GET request to:
GET /rest/workflows/{id}
Here's an example using curl:
curl --location 'https://your-n8n-instance.com/rest/workflows/123' \\
--header 'X-N8N-API-KEY: your_api_key'
Replace:
Step 4.3: Save the API response
The API will return the workflow in JSON format. You can save this response to a file to complete the export.
Step 4.4: Export all workflows via API
To retrieve all workflows, use:
GET /rest/workflows
Example curl command:
curl --location 'https://your-n8n-instance.com/rest/workflows' \\
--header 'X-N8N-API-KEY: your_api_key'
This will return an array of all workflows.
Step 5: Managing Exported Workflow Files
Once you've exported your workflows, proper management ensures they remain useful for backups or migrations.
Step 5.1: Organize exported workflows
Create a logical directory structure for your exported workflows. For example:
n8n-backups/
├── production/
│ ├── 2023-10-01/
│ └── 2023-11-01/
└── development/
└── 2023-10-15/
Step 5.2: Add version information
Consider adding the n8n version information to your exports, especially if you're planning to migrate between different n8n versions.
You can create a simple text file alongside your exports noting:
Step 5.3: Secure your exports
Workflow exports may contain sensitive information, even when credentials are removed. Store them securely:
Step 5.4: Implement regular automated backups
For production environments, set up automated regular exports:
#!/bin/bash
# Example backup script
DATE=$(date +%Y-%m-%d)
BACKUP\_DIR="/path/to/backups/$DATE"
mkdir -p $BACKUP\_DIR
n8n export:workflow --all --output="$BACKUP\_DIR/all-workflows.json"
# Optional: Compress the backup
tar -czf "$BACKUP_DIR.tar.gz" "$BACKUP_DIR"
rm -rf "$BACKUP\_DIR"
# Optional: Rotate old backups
find /path/to/backups/ -name "\*.tar.gz" -mtime +30 -delete
Step 6: Handling Credential Issues During Export/Import
One common challenge when exporting workflows is handling credentials properly.
Step 6.1: Understanding credential handling in exports
When you export a workflow with credentials:
Step 6.2: Exporting credentials separately (if needed)
If you need to migrate credentials as well, you can export them separately:
n8n export:credentials --all --output=all-credentials.json
Or for specific credentials:
n8n export:credentials --id=YOUR_CREDENTIAL_ID --output=specific-credential.json
Step 6.3: Documenting credential requirements
For workflows shared with others, create a README file documenting:
Step 6.4: Handling environment variables in credentials
If your workflow uses environment variables for sensitive information, document these requirements:
# Example documentation for required environment variables
API_KEY=your_api_key_here
DATABASE_PASSWORD=your_db\_password
WEBHOOK_SECRET=your_webhook\_secret
Step 7: Troubleshooting Export Issues
Sometimes you might encounter issues when exporting workflows. Here's how to troubleshoot common problems.
Step 7.1: Handling large workflows
If you have very large workflows, you might encounter timeout issues during export. To resolve this:
Step 7.2: Fixing permission issues in CLI exports
If you encounter permission issues when using the CLI:
sudo n8n export:workflow --id=YOUR_WORKFLOW_ID --output=/path/to/export.json
Or change the output location to a directory where your user has write permissions.
Step 7.3: Resolving export format errors
If your exported JSON appears malformed:
Step 7.4: Fixing API export authentication issues
If you're getting authentication errors when using the API:
Step 8: Additional Export Options and Best Practices
Advanced users can leverage additional export options for specific use cases.
Step 8.1: Exporting workflows for different environments
When exporting workflows for deployment across different environments (development, staging, production):
Step 8.2: Using tags for organized exports
Leverage n8n's tagging feature to organize workflows before export:
API example for exporting workflows with a specific tag:
curl --location 'https://your-n8n-instance.com/rest/workflows?filter=tags%3DmyTag' \\
--header 'X-N8N-API-KEY: your_api_key'
Step 8.3: Version control integration
For advanced users, integrate workflow exports with version control systems:
#!/bin/bash
# Example script to export workflows and commit to git
# Export all workflows
n8n export:workflow --all --output=workflows.json
# Commit and push to git
git add workflows.json
git commit -m "Automated workflow export $(date +%Y-%m-%d)"
git push origin main
Step 8.4: Handling custom nodes in exports
If your workflows use custom nodes:
Step 9: Importing Exported Workflows
For completeness, here's how to import the workflows you've exported.
Step 9.1: Import via the web interface
To import a workflow through the n8n web interface:
Step 9.2: Import via CLI
To import using the command line:
n8n import:workflow --input=my-workflow.json
For multiple workflows in a single file:
n8n import:workflow --separate --input=all-workflows.json
The --separate flag ensures each workflow is imported individually.
Step 9.3: Import via API
To import using the REST API:
curl --location --request POST 'https://your-n8n-instance.com/rest/workflows' \\
--header 'X-N8N-API-KEY: your_api_key' \\
--header 'Content-Type: application/json' \\
--data @path/to/your/workflow.json
Step 9.4: Verify the imported workflow
After importing:
Conclusion
Exporting workflows from n8n is a straightforward process that can be done through the web interface, command line, or API. Regular exports are essential for backup purposes, and the ability to share workflows makes collaboration easier. Remember to handle credentials carefully during the export process, especially when sharing workflows with others. By following the steps in this guide, you can effectively manage your n8n workflow exports for various use cases, from simple backups to complex environment migrations.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.