Skip to main content
RapidDev - Software Development Agency
n8n-tutorial

How to Export Workflows from n8n

Export workflows from n8n using the UI or the CLI. In the editor, open a workflow and select Menu then Download to save it as a JSON file. For bulk exports, use the n8n export:workflow --all command to export every workflow at once. These JSON files can be version-controlled, backed up, or imported into another n8n instance.

What you'll learn

  • How to export a single workflow from the n8n editor UI
  • How to export all workflows using the n8n CLI
  • How to automate workflow backups with a cron job
  • How to organize exported workflow files for version control
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read5 minutesn8n 0.170+ (self-hosted, Docker, n8n Cloud)March 2026RapidDev Engineering Team
TL;DR

Export workflows from n8n using the UI or the CLI. In the editor, open a workflow and select Menu then Download to save it as a JSON file. For bulk exports, use the n8n export:workflow --all command to export every workflow at once. These JSON files can be version-controlled, backed up, or imported into another n8n instance.

Why Export Workflows from n8n

Exporting workflows is essential for backups, version control, and migrating between n8n instances. Every n8n workflow is stored as a JSON object that describes nodes, connections, credentials references, and settings. When you export a workflow, you get a portable file you can share, commit to Git, or import into a different server. This tutorial covers both the visual UI method for single workflows and the CLI method for bulk exports.

Prerequisites

  • A running n8n instance with at least one saved workflow
  • Terminal access for CLI exports (self-hosted only)
  • Basic knowledge of JSON files and file management

Step-by-step guide

1

Export a single workflow from the UI

Open the workflow you want to export in the n8n editor. Click the three-dot menu icon in the top bar, then select Download. n8n saves the workflow as a JSON file to your browser's default download location. The file name matches the workflow name. This method works on both self-hosted and n8n Cloud instances. The exported file contains all node configurations, connections, and settings but does not include credential secrets — only credential references.

Expected result: A JSON file is downloaded to your computer containing the full workflow definition. The file can be opened in any text editor to inspect the structure.

2

Export all workflows using the CLI

For self-hosted n8n, the CLI provides a bulk export command. This exports every workflow in the database to individual JSON files in a specified directory. Each file is named with the workflow ID. This is the fastest way to create a full backup of all workflows. The CLI reads from the same database n8n uses, so make sure n8n has been started at least once to initialize the database.

typescript
1# Create a backup directory
2mkdir -p ~/n8n-backups/workflows
3
4# Export all workflows
5n8n export:workflow --all --output=~/n8n-backups/workflows/
6
7# Export a specific workflow by ID
8n8n export:workflow --id=5 --output=~/n8n-backups/workflows/workflow-5.json

Expected result: Individual JSON files are created in the backup directory, one per workflow. Each file contains the complete workflow definition.

3

Export workflows from Docker

When n8n runs in a Docker container, use docker exec to run the CLI inside the container. Make sure to specify the correct container name or ID. You can copy the exported files from the container to your host machine using docker cp, or mount a volume to write directly to the host filesystem.

typescript
1# Export all workflows inside the container
2docker exec -it n8n n8n export:workflow --all --output=/home/node/.n8n/backups/
3
4# Copy the backup folder to the host
5docker cp n8n:/home/node/.n8n/backups/ ~/n8n-backups/

Expected result: Workflow JSON files are exported inside the container and then copied to your host machine for safekeeping.

4

Automate exports with a cron job

Set up a cron job to automatically export workflows on a schedule. This creates timestamped backup directories so you have a history of workflow versions. Combine this with git commits to maintain full version control over your workflow definitions.

typescript
1# Add to crontab (crontab -e)
2# Export all workflows daily at 2 AM
30 2 * * * BACKUP_DIR=~/n8n-backups/$(date +\%Y-\%m-\%d) && mkdir -p $BACKUP_DIR && n8n export:workflow --all --output=$BACKUP_DIR/

Expected result: A new dated backup directory is created daily containing all workflow JSON files. Old backups are preserved for history.

5

Organize exports for Git version control

For teams, store exported workflows in a Git repository. This gives you change history, code review for workflow modifications, and easy rollback. Create a repository structure with a workflows directory and commit each export. Use meaningful commit messages that describe what changed in the workflows.

typescript
1# Initialize a Git repo for workflow backups
2mkdir -p ~/n8n-workflows-repo/workflows
3cd ~/n8n-workflows-repo
4git init
5
6# Export and commit
7n8n export:workflow --all --output=~/n8n-workflows-repo/workflows/
8git add workflows/
9git commit -m "Backup n8n workflows $(date +%Y-%m-%d)"

Expected result: Workflow JSON files are tracked in Git. You can view change history with git log and revert to any previous version.

Complete working example

backup-n8n-workflows.sh
1#!/bin/bash
2# backup-n8n-workflows.sh
3# Automated n8n workflow backup script with Git versioning
4
5set -euo pipefail
6
7# Configuration
8BACKUP_DIR="${HOME}/n8n-workflows-repo"
9WORKFLOW_DIR="${BACKUP_DIR}/workflows"
10LOG_FILE="${BACKUP_DIR}/backup.log"
11DATE=$(date +%Y-%m-%d_%H-%M-%S)
12
13# Create directories if they don't exist
14mkdir -p "${WORKFLOW_DIR}"
15
16# Initialize Git repo if not already initialized
17if [ ! -d "${BACKUP_DIR}/.git" ]; then
18 cd "${BACKUP_DIR}"
19 git init
20 echo "backup.log" > .gitignore
21 git add .gitignore
22 git commit -m "Initialize workflow backup repository"
23fi
24
25# Export all workflows
26echo "[${DATE}] Starting workflow export..." >> "${LOG_FILE}"
27
28if n8n export:workflow --all --output="${WORKFLOW_DIR}/" 2>> "${LOG_FILE}"; then
29 echo "[${DATE}] Export successful" >> "${LOG_FILE}"
30else
31 echo "[${DATE}] Export failed" >> "${LOG_FILE}"
32 exit 1
33fi
34
35# Commit changes if there are any
36cd "${BACKUP_DIR}"
37if [ -n "$(git status --porcelain)" ]; then
38 git add workflows/
39 git commit -m "Workflow backup ${DATE}"
40 echo "[${DATE}] Changes committed to Git" >> "${LOG_FILE}"
41else
42 echo "[${DATE}] No changes detected" >> "${LOG_FILE}"
43fi
44
45echo "[${DATE}] Backup complete" >> "${LOG_FILE}"

Common mistakes when exporting Workflows from n8n

Why it's a problem: Assuming exported workflows include credential secrets

How to avoid: Credential secrets are never included in exports. After importing, you must reconnect or re-enter credentials in the new instance.

Why it's a problem: Running the CLI export command while n8n is not installed globally

How to avoid: If you installed n8n with npx, use npx n8n export:workflow instead. For Docker, use docker exec to run the command inside the container.

Why it's a problem: Overwriting previous backups by exporting to the same directory without timestamps

How to avoid: Use timestamped directories (e.g., backups/2026-03-27/) or Git commits to preserve backup history.

Why it's a problem: Not testing that exported workflows can be imported successfully

How to avoid: Periodically import your backups into a test n8n instance to verify they are valid and complete.

Best practices

  • Export workflows before upgrading n8n to a new version as a safety net
  • Store exported JSON files in a Git repository for full change history and rollback capability
  • Automate daily exports with a cron job so you never lose more than a day of work
  • Test your exports by importing them into a staging n8n instance to verify they work
  • Note that exported files do not contain credential secrets — you must re-enter credentials after importing
  • Use descriptive workflow names so exported file names are meaningful
  • Keep at least 30 days of backup history before cleaning up old exports

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I need to export all my n8n workflows for backup and version control. Show me how to use the n8n CLI to export workflows, set up a cron job for daily backups, and commit the exports to a Git repository.

n8n Prompt

How do I export all my workflows from n8n? I want to back them up as JSON files and keep them in Git. Show me the CLI commands and a backup script.

Frequently asked questions

Do exported workflows include my API keys and credentials?

No. Exported workflow JSON files contain credential references (IDs) but never the actual secrets. After importing a workflow into a new instance, you must re-enter or reconnect all credentials.

Can I export workflows from n8n Cloud?

Yes. Use the UI method: open the workflow, click the three-dot menu, then select Download. The CLI export method is not available on n8n Cloud since you do not have terminal access.

What format are exported workflows in?

Workflows are exported as standard JSON files. Each file contains the complete workflow definition including nodes, connections, settings, and metadata.

Can I export a workflow and import it into an older version of n8n?

Workflows exported from a newer n8n version may use node types or settings that do not exist in older versions. This can cause import errors or missing node warnings. Always try to match versions.

How do I export just one workflow by its ID using the CLI?

Use n8n export:workflow --id=YOUR_WORKFLOW_ID --output=./my-workflow.json to export a single workflow. Replace YOUR_WORKFLOW_ID with the numeric ID shown in the workflow URL.

Can RapidDev help set up automated n8n workflow backups?

Yes. RapidDev can configure automated backup pipelines with Git versioning, offsite storage, and monitoring for your n8n deployment. Reach out for a free consultation.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.