Command-line tools for managing n8n workflows with version control and TypeScript support
npm install --save-dev n8n-workflow-managernpx n8n-workflow-manager init# Split n8n workflows into individual files
npx n8n-workflow-manager split
# Package files back into n8n workflow JSON
npx n8n-workflow-manager package
# Generate TypeScript types
npx n8n-workflow-manager types
Example: Splitting an n8n workflow into organized files
n8n-workflow-manager is a powerful CLI tool that helps you manage n8n workflows with proper version control, TypeScript support, and team collaboration features. It solves the common problems of:
- Version Control: n8n workflows are large JSON files that are difficult to version control and review
- Team Collaboration: Multiple developers can't easily work on the same workflow
- Code Organization: Complex workflows become hard to maintain and understand
- Type Safety: No TypeScript support for workflow development
- π Bidirectional Conversion: JSON β Individual Files
- π Smart File Organization: Automatic directory structure creation
- π― Interactive Workflow Selection: Choose which workflows to process
- π§ Configurable: Customize behavior via
n8n-config.json - π¦ Local Installation: No global dependencies required
- π·οΈ TypeScript Support: Generate type definitions for workflows
- πΎ Backup Creation: Automatic backups before packaging
- β Workflow Validation: Validate workflow structure and integrity
- π Progress Reporting: Detailed operation statistics
- π Code Node Extraction: Split JavaScript/TypeScript code into separate files
Initialize n8n workflow management in your project.
npx n8n-workflow-manager initOptions:
--force- Overwrite existing configuration
Extract n8n workflows into individual files for version control.
# Interactive selection
npx n8n-workflow-manager split
# Split all workflows
npx n8n-workflow-manager split --all
# Split specific workflow
npx n8n-workflow-manager split --workflow bug-trackerOptions:
--workflow <name>- Split specific workflow--all- Split all workflows--dry-run- Preview changes without making them
Package individual files back into n8n workflow JSON.
# Interactive selection
npx n8n-workflow-manager package
# Package all workflows
npx n8n-workflow-manager package --all
# Package specific workflow
npx n8n-workflow-manager package --workflow bug-trackerOptions:
--workflow <name>- Package specific workflow--all- Package all workflows--dry-run- Preview changes without making them
Generate TypeScript type definitions for workflows.
# Generate types for all workflows
npx n8n-workflow-manager types
# Generate types for specific workflow
npx n8n-workflow-manager types --workflow bug-trackerOptions:
--workflow <name>- Generate types for specific workflow--all- Generate types for all workflows--base- Generate base type definitions only
Create n8n-config.json in your project root to customize behavior:
{
"workflowsDir": "workflows",
"n8nDir": "n8n",
"generateTypes": true,
"typeScript": {
"enabled": true,
"outputDir": "types"
},
"ignore": [
"node_modules",
".git",
".env",
".env.*"
],
"extraction": {
"preserveIds": true,
"generateIndex": true,
"splitCodeNodes": true
},
"packaging": {
"validateWorkflows": true,
"minifyOutput": false,
"backupOriginal": true
}
}| Option | Description | Default |
|---|---|---|
workflowsDir |
Directory for extracted workflows | workflows |
n8nDir |
Directory for n8n JSON files | n8n |
generateTypes |
Generate TypeScript types | true |
typeScript.enabled |
Enable TypeScript support | true |
typeScript.outputDir |
TypeScript output directory | types |
extraction.preserveIds |
Keep original node IDs | true |
extraction.generateIndex |
Generate node index files | true |
extraction.splitCodeNodes |
Split code nodes into separate files | true |
packaging.validateWorkflows |
Validate workflow structure | true |
packaging.backupOriginal |
Backup before packaging | true |
Example: Edit workflow code directly in your IDE with syntax highlighting
After initialization, your project will have:
your-project/
βββ n8n/ # n8n workflow JSON files
β βββ bug-tracker.json # Original workflow exports
β βββ github-pr.json
βββ workflows/ # Extracted workflow files
β βββ bug-tracker/
β β βββ workflow.json # Base workflow structure
β β βββ metadata.json # Workflow metadata
β β βββ connections.json # Node connections
β β βββ nodes/ # Individual node files
β β β βββ webhook.json
β β β βββ code-node.js
β β β βββ linear-create.json
β β βββ types/ # TypeScript definitions
β β βββ nodes.d.ts
β βββ github-pr/
β βββ ...
βββ types/ # Global TypeScript types
β βββ n8n-workflows.d.ts
βββ n8n-config.json # Configuration file
Available on all commands:
--config <path>- Path to config file (default:n8n-config.json)--verbose- Enable verbose logging--dry-run- Show what would be done without making changes--help- Show help information
- Split workflows into individual files for easier code review
- Version control each node and connection separately
- Merge conflicts become manageable with individual files
- Parallel development on different parts of the same workflow
- Extract code nodes into separate
.js/.tsfiles - Organize complex workflows into logical file structures
- Reuse common nodes across multiple workflows
- Generate TypeScript types for better development experience
- Validate workflows before deployment
- Automatic packaging in build pipelines
- Type checking for workflow code
- Backup creation before updates
# Initialize project
npx n8n-workflow-manager init
# Place your n8n workflow JSON files in the n8n/ directory
cp my-workflow.json n8n/
# Split into individual files
npx n8n-workflow-manager split
# Edit files in workflows/ directory
# ...make changes...
# Package back to JSON
npx n8n-workflow-manager package# Generate TypeScript types
npx n8n-workflow-manager types
# Your code nodes can now use proper types
// workflows/my-workflow/nodes/process-data.ts
import { N8nNode, WorkflowContext } from '../types/nodes';
export function processData(context: WorkflowContext): N8nNode {
// Type-safe workflow development
return {
json: {
processed: true,
data: context.inputData
}
};
}# .github/workflows/n8n-workflows.yml
name: n8n Workflows
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Validate workflows
run: npx n8n-workflow-manager package --dry-run
- name: Generate types
run: npx n8n-workflow-manager types
- name: Type check
run: npx tsc --noEmitTo contribute to this project:
-
Clone the repository:
git clone https://github.com/northfacejmb/n8n-workflow-manager.git cd n8n-workflow-manager -
Install dependencies:
npm install
-
Run linting:
npm run lint
-
Test your changes:
npm test
Contributions are welcome! Please see CONTRIBUTING.md for details.
Quick ways to contribute:
- π Report bugs
- π‘ Request features
- π Improve documentation
- π§ Submit pull requests
MIT Β© Jeremy Press
- π¦ npm Package - Install and use the CLI tool
- π GitHub Repository - Source code and development
- π Issue Tracker - Report bugs and request features
- π n8n Documentation - Learn about n8n workflows
Made with β€οΈ for the n8n community