VS Code Extension Guide
The n8n-as-code VS Code Extension transforms VS Code into a focused IDE for n8n workflows. It provides visual editing, explicit git-like workflow controls, and workflow validation.
🎨 Features
🔄 Git-like Synchronization
The extension follows a git-like workflow with explicit commands. View workflow status, pull changes, and push local changes using the context menu. Local file additions and deletions are reflected in the tree, while remote state is refreshed when you ask for it.
🗂️ Multi-Instance Support
Your workflows are automatically organized by instance to avoid mixing files from different environments:
workflows/instance_name_user/my_workflow.json
🎯 Visual Status Indicators
The tree view displays color-coded icons showing the sync status of each workflow at a glance:
- 📄 Plain file -
TRACKED: Both local and remote exist (in sync) - ☁️ Blue cloud -
EXIST_ONLY_REMOTELY: Remote workflow not yet pulled locally - 📄+ Orange file-add -
EXIST_ONLY_LOCALLY: New local workflow not yet pushed - 🔴 Red alert -
CONFLICT: Both sides modified since last sync, requires resolution
🛡️ Persistent Conflict Resolution UI
Workflows in conflict state become expandable tree items with child action buttons, ensuring you never lose track of issues that need resolution:
For Conflicts:
- 📄 Show Diff - Opens a side-by-side diff view comparing local and remote versions
- ✅ Keep Local Version - Force push local changes to remote (overwrite remote)
- ☁️ Keep Remote Version - Force pull remote changes to local (overwrite local)
These actions remain visible in the tree until resolved, preventing conflicts from being forgotten or lost.
🛠️ Built-in Validation & Snippets
Your environment is automatically configured with validation and snippets upon opening:
- JSON Validation: n8n schema applied for input assistance and live error detection
- Snippet Library: Ready-to-use node templates (
node:webhook,node:code, etc.)
🍱 Split View
Visualize the n8n canvas beside your code using the integrated Webview while editing the workflow file. This is the ideal interface for structurally validating changes before you push.
⚙️ Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "n8n-as-code"
- Click Install
From VSIX File
- Download the
.vsixfile from releases - In VS Code, go to Extensions
- Click "..." menu and select "Install from VSIX"
- Select the downloaded file
🔧 Configuration
Initial Setup
- Click the n8n icon in the Activity Bar
- Click n8n: Configure (or the Configure link shown in the panel)
- Enter your Host and API Key:
- The extension automatically loads available projects as you type
- Your Personal project is pre-selected by default
- Configure:
- Sync Folder (default:
workflows)
- Sync Folder (default:
- Click Save settings
- Click Initialize n8n as code in the n8n view to initialize the workspace and load the active project context
The extension stores the active workspace configuration in n8nac-config.json. Legacy n8n.* VS Code settings remain as a fallback compatibility layer, not the primary source of truth.
Apply Changes (safety)
When you change critical settings (host / API key / sync folder / project), synchronization is paused and an Apply Changes action appears (status bar and n8n panel). This prevents partial or accidental settings edits from triggering unexpected sync behavior.
Settings Reference
| Parameter | Description | Default |
|---|---|---|
n8n.host | URL of your n8n instance | - |
n8n.apiKey | Your n8n API Key | - |
n8n.syncFolder | Local storage folder | workflows |
n8n.projectId | Project ID to sync (selected via Configure) | - |
n8n.projectName | Project name (selected via Configure) | - |
📖 Usage
Connecting to n8n
The extension automatically connects to n8n when:
- You have initialized the workspace or configured the required connection values
- You open a workspace with the extension
- The extension validates the connection automatically
If connection fails, check the Output panel (View > Output, select "n8n-as-code") for error details.
Fetching & Pulling Workflows
- Click the refresh button in the n8n panel to update the remote state cache and see current status
- Right-click a workflow and select Pull to download it locally
- Workflows are organized by instance in your local directory
Editing Workflows
- Click a workflow in the tree view to open the JSON editor
- For split view with canvas preview:
- Click "Open Workspace" action button
- Or use the context menu option
- The split view shows:
- Left: JSON editor
- Right: n8n canvas preview
- Make changes in the JSON editor
- Right-click the workflow in the tree view and select Push to send your changes to n8n
Creating New Workflows
To create a new workflow:
- Create a new JSON file in your workflows directory
- Use the n8n schema for structure guidance
- Right-click the file in the tree view and select Push to upload it to n8n
Resolving Conflicts
When a workflow has a conflict (both local and remote modified):
- The workflow appears with a 🔴 red alert icon in the tree
- Expand the workflow to see resolution actions:
- 📄 Show Diff - View differences between versions
- ✅ Keep Local Version - Push your local changes
- ☁️ Keep Remote Version - Pull remote changes
- Click the desired action to resolve
- The workflow returns to
TRACKEDstate
🔄 Sync Behavior
Git-like Explicit Sync
All sync operations that move workflow state are user-triggered. Follow this git-like pattern:
- List: Right-click a workflow or use the tree refresh to see current sync status
- Fetch: Fetch remote state to update the local cache for accurate status
- Pull: Download remote changes you want to incorporate
- Edit: Make your changes locally
- Push: Upload your changes back to n8n
This explicit model gives you full control and prevents unexpected overwrites.
3-Way Merge Detection
The extension uses a sophisticated 3-way merge algorithm to detect conflicts:
- Tracks the base state (last synced version) in
.n8n-state.json - Compares local version (file on disk)
- Compares remote version (workflow in n8n)
- Only flags as conflict when both local AND remote have changed since the base
- This prevents false positive conflicts and enables deterministic sync behavior
🤝 AI Agent Support
Context Generation for AI Assistants
The extension works with the CLI to generate context files that empower AI coding assistants:
AGENTS.md: Instructions for AI assistants on n8n workflow development.vscode/n8n.code-snippets: Code snippets for autocomplete (generated from n8n-nodes-index.json).vscode/n8n.code-snippets: Code snippets for common n8n node patterns
How AI Assistants Leverage These Files
AI coding assistants (like Cursor, Copilot, Claude, etc.) can use these generated files to:
- Understand n8n workflow structure and best practices
- Provide accurate code suggestions based on node schemas
- Validate workflow JSON against the n8n schema
- Generate common node patterns using pre-built snippets
🎯 Tips & Best Practices
Workflow Organization
- Use folders in n8n to organize workflows
- The extension mirrors the folder structure locally
- Keep related workflows together
Version Control
- Commit workflow JSON files to Git
- Use meaningful commit messages
- Review changes using Git diff
Backup Strategy
- Regular commits to Git
- Export workflows from n8n as backup
- Use the extension's sync as primary backup
🚨 Troubleshooting
Common Issues
Extension not connecting
- Check n8n URL and API key
- Verify n8n instance is accessible
- Check network connectivity
Sync not working
- Use Fetch from the context menu to refresh remote state
- Verify file permissions
- Check network connectivity
Canvas not loading
- Check n8n URL is correct
- Verify API key has proper permissions
- Try refreshing the webview
Getting Help
- Check the Troubleshooting guide
- Search existing issues
- Ask in GitHub Discussions
📚 Next Steps
- CLI Guide: Learn about command-line automation
- Contribution Guide: Understand the architecture
The VS Code Extension provides the most direct way to review status, edit locally, preview structure, and push intentionally.