A powerful CLI tool for managing n8n workflows across multiple environments with support for tags, validation, and automated deployment.
-
π Workflows as Code - Store workflows in Git alongside your project code
-
π·οΈ Organized by Categories - Tag and filter workflows by project/team using n8n tags
-
π Bi-directional Sync - Pull workflows from n8n, edit locally, and deploy back
-
β Workflow validation - Comprehensive JSON schema validation
-
π Pull/Push workflows - Sync workflows between environments
-
π‘οΈ Safe Deployments - New workflows are created inactive; no duplicate workflows
-
β‘ Parallel deployment - Deploy multiple workflows simultaneously
-
π Dry-run mode - Test deployments without making changes
Install globally to use across all your workflow projects:
npm install -g @integratingfactor/n8n-workflow-cliVerify installation:
n8n-workflow-cli -hPull workflows from n8n to local files:
n8n-workflow-cli pull [options]
Options:
--category <category>- Only pull workflows with this category tag
Examples:
# Pull all workflows
n8n-workflow-cli pull
# Pull only business workflows
n8n-workflow-cli pull --category businessCompare local workflows with remote n8n instance:
n8n-workflow-cli diff [workflow]Arguments:
workflow(optional) - Specific workflow file, category, or omit to compare all
Examples:
# Compare all workflows
n8n-workflow-cli diff
# Compare specific workflow
n8n-workflow-cli diff workflows/business/my-workflow.json
# Compare all workflows in a category
n8n-workflow-cli diff businessOutput:
- Modified: Workflows that differ between local and remote
- Local Only: Workflows present locally but not in n8n
- Remote Only: Workflows present in n8n but not locally
- Identical: Workflows that match between local and remote
Deploy local workflows to n8n:
n8n-workflow-cli deploy [options]
Options:
--dry-run- Show what would be deployed without making changes
Examples:
# Deploy all workflows
n8n-workflow-cli deploy
# Preview deployment without making changes
n8n-workflow-cli deploy --dry-run
Behavior:
- New workflows: Created as inactive (must be manually activated in n8n)
- Existing workflows: Updated with local changes
- Duplicate prevention: Checks for existing workflows by name before creating
- Tags: Automatically creates and assigns category tags
List workflows:
n8n-workflow-cli list [options]Options:
--remote- List workflows from n8n instance (also) along with local files
Examples:
# List local workflows
n8n-workflow-cli list
# List remote workflows
n8n-workflow-cli list --remoteValidate local workflow JSON files:
n8n-workflow-cli validateChecks for:
- Valid JSON structure
- Required workflow fields
- Proper node configuration
- Connection validity
A typical workflow project looks like this:
my-n8n-workflows/
βββ .env # Environment variables (gitignored)
βββ .gitignore # Ignore .env and other files
βββ n8n.config.json # Tool configuration
βββ README.md # Project documentation
βββ workflows/ # Workflow JSON files
βββ business/
β βββ customer-onboarding.json
β βββ invoice-processing.json
βββ management/
β βββ team-reports.json
βββ shared/
βββ send-notification.json
Create a new directory for your n8n workflows:
mkdir my-n8n-workflows
cd my-n8n-workflows
git initCreate n8n.config.json in your project root:
{
"workflowsDir": "./workflows",
"categories": ["business", "management", "shared"]
}Configuration Options:
workflowsDir: Directory where workflow JSON files are stored (relative to config file)categories: List of workflow categories (used as n8n tags for organization)
π‘ Important: The
n8n.config.jsonfile should be committed to your repository.
The CLI uses two simple environment variables:
N8N_API_URL- Your n8n instance API URL (must end with/api/v1)N8N_API_KEY- Your n8n API key (from Settings β API in n8n)
Option 1: Using .env file (recommended for local development)
# Edit .env with your values
N8N_API_URL=https://n8n.dev.company.com/api/v1
N8N_API_KEY=your-dev-api-key
# Add `.env` to your `.gitignore`:
echo ".env" >> .gitignoreOption 2: Using shell exports
export N8N_API_URL="https://n8n.dev.company.com/api/v1"
export N8N_API_KEY="your-dev-api-key"Categories help organize workflows into folders in your repository:
-
Define categories in the
categoriesarray - customize for your project needs (e.g.,["business", "management", "shared"]) -
Commit the config - The
n8n.config.jsonfile with your categories should be committed so the team shares the same organization -
Tag workflows in n8n - Only workflows with tags matching a category name will be pulled
This creates workflow JSON files in your workflowsDir, organized by category.
# Pull all workflows with matching category tags
n8n-workflow-cli pull
# Pull only workflows tagged with "business"
n8n-workflow-cli pull --category businessn8n-workflow-cli validateEdit workflow files locally, then deploy:
# deploy a specific workflow
n8n-workflow-cli deploy workflows/business/my-workflow.json
# deploy all workflows
n8n-workflow-cli deployImportant: New workflows are created as inactive for safety. You must:
-
Verify the workflow in n8n UI
-
Configure credentials and connections
-
Test the workflow
-
Manually activate it when ready
- Commit workflow JSON files to Git
- Use meaningful commit messages describing workflow changes
- Review diffs before committing to catch unintended changes
- Keep
.envin.gitignore(never commit credentials)
- Use pull requests for workflow changes
- Document complex workflows in comments
- Use consistent category naming across team
- Set up CI/CD to validate workflows automatically
- Keep separate n8n instances for dev/staging/prod
- Test workflows in dev before deploying to prod
- Use environment-specific credentials in n8n
- Document environment differences in your project README
- Use meaningful workflow names
- Group related workflows in categories
- Keep workflows focused on single responsibilities
- Document dependencies between workflows
- Always run
validatebefore deploying - Use
--dry-runto preview changes - Test new workflows in n8n before activating
- Review credential mappings after deployment
Make sure your N8N_API_URL includes the full API path:
# β
Correct
N8N_API_URL=https://n8n.example.com/api/v1
# β Wrong
N8N_API_URL=https://n8n.example.com- Verify your API key is correct
- Check that API access is enabled in n8n (Settings β API)
- Ensure your n8n instance is accessible from your machine
If a workflow was deleted in n8n but exists locally:
- The tool will check if a workflow with the same name exists
- If found, it updates the existing workflow
- If not found, it creates a new workflow (inactive)
- Local file is updated with the correct workflow ID
The tool prevents duplicates by checking workflow names before creating. If you see duplicates:
- They were likely created outside this tool
- Manually delete duplicates in n8n UI
- Run
pullto sync local files with n8n state
- Issues: Report bugs and request features on GitHub Issues
- Development: See DEVELOPMENT.md for contributing guidelines
- License: MIT
See CHANGELOG.md for version history and release notes.
Made with β€οΈ for the n8n community