Skip to content

Automations-Project/n8n-workflows-comparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N8N Workflow Comparator

License: MIT

Developed VibeCoded by Nskha - Your n8n Projects Team

A simple powerful Node.js tool to compare n8n workflow backup files and identify differences between them.

Features

  • 🔍 Compare workflow files - Identify added, removed, and modified workflows
  • 📊 Detailed analysis - See exactly what changed in each workflow
  • 🔧 Node-level comparison - Track changes to individual nodes
  • 📝 Multiple output formats - Console output, JSON reports, or summary-only
  • 💾 Report generation - Save detailed comparison reports to JSON files

Installation

Option 1: Clone from GitHub

git clone https://github.com/Automations-Project/n8n-workflows-comparator.git
cd n8n-workflows-comparator

Option 2: Install as a Global Package (Coming soon)

npm install -g n8n-workflows-comparator

Once installed globally, you can use the tool from anywhere with:

n8n-compare file1.json file2.json

Option 3: Use with npx (Coming soon)

npx n8n-workflows-comparator file1.json file2.json
  1. Install Node.js (if not already installed):

    • Download from nodejs.org
    • Version 14 or higher required
  2. Place your workflow input files in a data subdirectory:

    n8n-workflows-comparator/
    └── data/
        ├── workflows_old.json  # Example input file
        └── workflows_new.json  # Another example input file
    

    The scripts will automatically look for input files in this data directory.

Usage

Important Directory Structure:

  • Place all your input workflow JSON files (e.g., workflows_old.json, file1.json) into a subdirectory named data.
  • Detailed comparison reports generated by the scripts will be automatically saved into a subdirectory named results (the results directory will be created if it doesn't exist).

The commands below assume you are running them from the root of your n8n-workflow-compare project directory.

Method 1: Basic Script

# Edit file paths in the script first, then run
node compare-workflows.js

Method 2: CLI with Arguments (Recommended)

# Compare workflows - (1) as OLD baseline vs (2) as NEW
node cli-compare.js "workflows_old.json" "workflows_new.json"

# Show only summary without detailed node changes
node cli-compare.js file1.json file2.json --summary

# Output as JSON for further processing
node cli-compare.js file1.json file2.json --json

# Save JSON report to file
node cli-compare.js file1.json file2.json --json > comparison-report.json

# Reverse comparison direction (if needed)
node cli-compare.js "workflows_new.json" "workflows_old.json" --reverse

Understanding the Comparison Direction

Important: The comparison always shows changes from OLD → NEW:

  • OLD FILE (first argument): Your baseline/reference version
  • NEW FILE (second argument): The version you're comparing against
  • "Added" means: Present in NEW but not in OLD
  • "Removed" means: Present in OLD but not in NEW
  • "Modified" means: Different between OLD and NEW versions

Example:

node cli-compare.js "workflows_old.json" "workflows_new.json"

This shows: What changed from version (1) to version (2)

Quick File Identification

Automatic File Detection

The script automatically shows you:

  • File paths and names for easy identification
  • File modification timestamps to help determine which is newer
  • Workflow counts in each file
  • Clear direction indicators (OLD → NEW)

Manual File Ordering

If you want to control which file is treated as "old" vs "new":

# Treat (1) as baseline, (2) as new version
node cli-compare.js "workflows_old.json" "workflows_new.json"

# Treat (2) as baseline, (1) as new version  
node cli-compare.js "workflows_new.json" "workflows_old.json"

# Or use --reverse flag to flip the comparison
node cli-compare.js "workflows_old.json" "workflows_new.json" --reverse

Reading the Results

  • "Added in X" = These workflows exist in file X but not in the other
  • "Removed from Y" = These workflows existed in file Y but not in the comparison file
  • "Modified between versions" = These workflows exist in both files but have differences

Understanding the Comparison Direction

# Initialize the project
npm init -y

# Run with npm
npm start
# or
npm run compare

Example Output

🔍 Starting workflow comparison...

📁 COMPARISON SETUP:
   OLD FILE (baseline): workflows_old.json
   ├─ Path: /your/path/workflows_old.json
   ├─ Modified: 2024-01-15T10:30:00.000Z
   └─ Workflows: 45
   NEW FILE (compared): workflows_new.json
   ├─ Path: /your/path/workflows_new.json
   ├─ Modified: 2024-01-16T14:20:00.000Z
   └─ Workflows: 47

🔄 CHANGES: OLD → NEW

================================================================================
🔄 Changes from workflows_old.json → workflows_new.json
================================================================================

🆕 WORKFLOWS ADDED in workflows_new.json (2):
   ✅ New Automation Workflow
      └─ ID: abc123
   ✅ Data Processing Pipeline
      └─ ID: def456

🗑️  WORKFLOWS REMOVED from workflows_old.json (0):
   (none)

🔄 WORKFLOWS MODIFIED between versions (3):
   🔧 Customer Sync Process
      └─ ID: xyz789
      └─ Changes: metadata, +1 nodes, ~2 nodes
   🔧 Email Campaign Manager
      └─ ID: uvw012
      └─ Changes: ~1 nodes, connections

✅ WORKFLOWS UNCHANGED (42):
   ≡ 42 workflows remain identical
   └─ (Use detailed report to see full list)

================================================================================
📊 SUMMARY: 2 added, 0 removed, 3 modified, 42 unchanged
================================================================================

📄 DETAILED CHANGES REPORT

====================================================================================================
🔍 Detailed analysis of changes from workflows_old.json → workflows_new.json
====================================================================================================

1. WORKFLOW: "Customer Sync Process" (ID: xyz789)
------------------------------------------------------------
   📝 Metadata Changes:
      updatedAt:
        OLD (workflows_old.json): "2024-01-15T10:30:00Z"
        NEW (workflows_new.json): "2024-01-16T14:20:00Z"
   ➕ Nodes Added in workflows_new.json:
      ✅ "Data Validation" (If) - ID: node123
   🔧 Nodes Modified between versions:
      🔄 "HTTP Request" (HTTP Request) - ID: node456
         • url:
           OLD: "api.old.com"
           NEW: "api.new.com"
         • parameters: configuration modified

💾 Detailed report saved to: results/workflow-comparison-workflows_6_json-vs-workflows_7_json.json
📊 Report includes comparison from workflows_old.json → workflows_new.json

File Structure

The recommended directory structure is:

n8n-workflow-compare/
├── data/                      # Directory for your input workflow JSON files
│   ├── workflows_old.json     # Example input file 1
│   └── workflows_new.json     # Example input file 2
├── results/                   # Directory for generated detailed comparison reports
│   └── workflow-comparison-...json # Example generated report file
├── compare-workflows.js       # Main comparison logic
├── cli-compare.js             # Command-line interface script
└── package.json               # Node.js project file (if you use npm init)

Input workflow files should be placed in the data directory. Detailed comparison reports generated by the scripts will be saved in the results directory.

What Gets Compared

Workflow Level

  • ✅ Workflow name
  • ✅ Active status
  • ✅ Last updated timestamp
  • ✅ Trigger count
  • ✅ Workflow settings
  • ✅ Node connections

Node Level

  • ✅ Node name and type
  • ✅ Node parameters
  • ✅ Node position
  • ✅ Node credentials
  • ✅ Added/removed nodes
  • ✅ Modified node configurations

Customization

You can modify the comparison criteria by editing the compareWorkflows() and compareNodes() functions in compare-workflows.js.

Adding Custom Comparison Fields

// In compareWorkflows function, add more metadata fields:
const metadataFields = ['name', 'active', 'updatedAt', 'triggerCount', 'tags', 'meta'];

// In compareNodes function, add more node properties:
if (node1.someCustomProperty !== node2.someCustomProperty) {
    changes.someCustomProperty = { old: node1.someCustomProperty, new: node2.someCustomProperty };
}

Troubleshooting

Common Issues

  1. "File not found" error

    • Check file paths are correct
    • Use quotes around filenames with spaces
    • Ensure files are in the same directory as the script
  2. "Cannot parse JSON" error

    • Verify the workflow files are valid JSON
    • Check for file corruption
    • Ensure files are complete n8n exports
  3. Memory issues with large files

    • For very large workflow files (>100MB), consider splitting them
    • Increase Node.js memory limit: node --max-old-space-size=4096 compare-workflows.js

Performance Tips

  • For faster comparisons of large files, you can disable detailed node parameter comparison
  • Use --summary flag for quick overview without detailed analysis
  • Save results to JSON for further processing with other tools

About Automations-Project

Automations-Project is a specialized agency focusing on n8n automation workflows. We provide:

  • Custom n8n workflow development
  • n8n workflow optimization
  • Integration services
  • Training and support

For more information about our services, please contact us or visit our website.

License

MIT License - Copyright (c) 2025 Automations-Project

This project is licensed under the MIT License - see the LICENSE file for details.

About

Compare n8n workflows JSON files, track backups changes, and generate detailed diff reports. A CLI tool for n8n version management.

Topics

Resources

License

Stars

Watchers

Forks