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
Export a single workflow from the UI
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.
Export all workflows using the CLI
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.
1# Create a backup directory2mkdir -p ~/n8n-backups/workflows34# Export all workflows5n8n export:workflow --all --output=~/n8n-backups/workflows/67# Export a specific workflow by ID8n8n export:workflow --id=5 --output=~/n8n-backups/workflows/workflow-5.jsonExpected result: Individual JSON files are created in the backup directory, one per workflow. Each file contains the complete workflow definition.
Export workflows from Docker
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.
1# Export all workflows inside the container2docker exec -it n8n n8n export:workflow --all --output=/home/node/.n8n/backups/34# Copy the backup folder to the host5docker 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.
Automate exports with a cron job
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.
1# Add to crontab (crontab -e)2# Export all workflows daily at 2 AM30 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.
Organize exports for Git version control
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.
1# Initialize a Git repo for workflow backups2mkdir -p ~/n8n-workflows-repo/workflows3cd ~/n8n-workflows-repo4git init56# Export and commit7n8n 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
1#!/bin/bash2# backup-n8n-workflows.sh3# Automated n8n workflow backup script with Git versioning45set -euo pipefail67# Configuration8BACKUP_DIR="${HOME}/n8n-workflows-repo"9WORKFLOW_DIR="${BACKUP_DIR}/workflows"10LOG_FILE="${BACKUP_DIR}/backup.log"11DATE=$(date +%Y-%m-%d_%H-%M-%S)1213# Create directories if they don't exist14mkdir -p "${WORKFLOW_DIR}"1516# Initialize Git repo if not already initialized17if [ ! -d "${BACKUP_DIR}/.git" ]; then18 cd "${BACKUP_DIR}"19 git init20 echo "backup.log" > .gitignore21 git add .gitignore22 git commit -m "Initialize workflow backup repository"23fi2425# Export all workflows26echo "[${DATE}] Starting workflow export..." >> "${LOG_FILE}"2728if n8n export:workflow --all --output="${WORKFLOW_DIR}/" 2>> "${LOG_FILE}"; then29 echo "[${DATE}] Export successful" >> "${LOG_FILE}"30else31 echo "[${DATE}] Export failed" >> "${LOG_FILE}"32 exit 133fi3435# Commit changes if there are any36cd "${BACKUP_DIR}"37if [ -n "$(git status --porcelain)" ]; then38 git add workflows/39 git commit -m "Workflow backup ${DATE}"40 echo "[${DATE}] Changes committed to Git" >> "${LOG_FILE}"41else42 echo "[${DATE}] No changes detected" >> "${LOG_FILE}"43fi4445echo "[${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.
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.
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.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation