/n8n-tutorials

How to export workflows from n8n?

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.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to export workflows from n8n?

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:

  • JSON: Standard format that includes all workflow data
  • Shareable Link: Creates a link that others can use to import your workflow
  • JSON (without credentials): Exports the workflow without sensitive credential information

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:

  • Your n8n instance URL
  • API authentication (usually an API key or access token)

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:

  • "your-n8n-instance.com" with your actual n8n URL
  • "123" with your workflow ID
  • "your_api_key" with your actual API key

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:

  • n8n version
  • Export date
  • Any special configurations

Step 5.3: Secure your exports

Workflow exports may contain sensitive information, even when credentials are removed. Store them securely:

  • Use encryption for backup files
  • Restrict access to export directories
  • Don't store workflow exports in public repositories

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:

  • Credential IDs are included in the export
  • The actual credential values (passwords, API keys, etc.) are NOT included
  • If you use "Export without credentials", even the credential IDs are removed

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:

  • Which credential types are needed
  • What permissions are required
  • Step-by-step instructions for setting up the credentials

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:

  • Use the CLI export method instead of the web interface
  • Export individual workflows rather than exporting all at once
  • Increase any timeout settings in your environment

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:

  • Verify you're using the latest n8n version
  • Try exporting in smaller batches
  • Check if any nodes in your workflow are causing issues by creating a simplified test workflow

Step 7.4: Fixing API export authentication issues

If you're getting authentication errors when using the API:

  • Verify your API key is correct and not expired
  • Check that your API key has the correct permissions
  • Ensure you're including the API key in the correct header format

 

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

  • Use environment variables for configuration values
  • Export without credentials and manage them separately per environment
  • Document any environment-specific settings

Step 8.2: Using tags for organized exports

Leverage n8n's tagging feature to organize workflows before export:

  • Tag related workflows with consistent labels
  • Filter workflows by tags in the UI before batch export
  • Use the API to export workflows with specific tags

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:

  • Document custom node dependencies in a README file
  • Include installation instructions for custom nodes
  • Consider packaging custom nodes with your workflow exports

 

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:

  • Click on "Workflows" in the left sidebar
  • Click the "Import from file" button (or "Import from URL" if you have a shared link)
  • Select your exported JSON file
  • Review the workflow and click "Import" to confirm

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:

  • Check that all nodes were imported correctly
  • Verify or reconfigure any credentials
  • Test the workflow with a sample execution
  • Adjust any environment-specific settings

 

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.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022