What is n8n?
n8n (pronounced "n-eight-n", short for "nodemation") is a source-available workflow automation platform that lets you connect apps, APIs, databases, and AI models using a visual, node-based editor. It is often described as a self-hostable alternative to Zapier or Make, but with far more flexibility, code support, and no per-task pricing.
Key Characteristics
- Visual workflow editor — drag-and-drop nodes on a canvas.
- Self-hostable — run on your own infrastructure (Docker, Kubernetes, bare metal).
- Code when you need it — drop into JavaScript or Python inside any workflow.
- Event-driven & scheduled — webhooks, cron, app triggers, polling.
- AI-native — built-in LangChain nodes for agents, RAG, and vector stores.
- Fair-code license — free for internal use, paid for enterprise features.
Core Concepts
A collection of connected nodes that runs from a trigger to completion. The top-level unit of automation.
A single step in a workflow. Each node performs one action: fetch data, transform it, send a message, call an API.
The first node in a workflow. It decides when the workflow runs: on a schedule, on a webhook, on an app event.
The unit of data passed between nodes. A node can output one item or thousands. n8n processes items in a list.
Dynamic values written in {{ }} syntax. Used to reference data from previous nodes, env vars, or dates.
Stored authentication (API key, OAuth2, token) that nodes use to connect to external services. Encrypted at rest.
A workflow called by another workflow via the Execute Workflow node. Enables modular, reusable logic.
A single run of a workflow. n8n stores execution data (input/output per node) for debugging and auditing.
Anatomy of a Node
Every node in n8n shares a common structure. Understanding this makes any node easy to configure.
| Component | What it does | Examples |
|---|---|---|
| Credentials | Authentication method used to connect to the service | OAuth2, API Key, Basic Auth, JWT, Service Account |
| Resource | The main object type you want to work with | Message, Sheet, Record, File, Contact |
| Operation | The action performed on the resource | Get, Create, Update, Delete, Send, List |
| Parameters | Required fields for the chosen operation | Channel, Text, To, Subject, Table, Query |
| Options | Advanced / optional settings | Pagination, Timeout, Retry, Attachments, Filters |
| Input | Data received from the previous node | Items (JSON array) |
| Output | Data passed to the next node | Items (JSON array), Binary, Error |
| Settings | Node-level behavior controls | Retry on Fail, Continue on Fail, Execute Once, Timeout, Notes |
Universal Node Settings
- Always Output Data — emit an empty item if the node returns nothing.
- Execute Once — run only once even if there are multiple input items.
- Retry On Fail — automatically retry after failure (with configurable wait).
- Continue On Fail — keep the workflow running if this node errors.
- On Error — stop workflow, continue, or route to an error output.
- Timeout — maximum execution time for the node.
- Notes — add documentation visible on the canvas.
How Data Flows
n8n passes data as an array of items. Each item is a JSON object. Nodes process the list item-by-item by default, but some nodes (like Merge or Code in "all items" mode) operate on the whole list.
Item Structure
[
{
"json": {
"id": 1,
"name": "Alice",
"email": "alice@example.com"
},
"binary": { }
}
]
Core Logic & Data Nodes
These nodes appear in almost every workflow. Master them first.
HTTP Request Core
The universal connector. Use it for any REST API that doesn't have a dedicated n8n node.
- Method — GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
- URL — static or expression-based.
- Authentication — None, Predefined Credential Type, Generic (Basic, Digest, Header, Query, OAuth1, OAuth2, API Key).
- Headers / Query Params — key-value pairs, expressions allowed.
- Body — JSON, Form-Data, Form URL Encoded, Raw, Binary.
- Options — Pagination, Timeout, Redirects, Proxy, SSL, Response Format, Batching.
Code Core
Run custom JavaScript or Python for complex transformations.
- Mode — Run Once for All Items / Run Once for Each Item.
- Language — JavaScript or Python (Beta).
- Built-in variables —
$input,$json,$node,$items,$workflow,$execution,$env,$secrets.
IF Core
Conditional branching — sends items down the true or false path.
- Conditions — Value 1, Operation, Value 2.
- Operations — String, Number, Date, Boolean, Array, Object comparisons.
- Combinator — AND (all must match) / OR (any must match).
- Options — Ignore Case, Less Strict Type Validation, Convert Types.
Switch Core
Routes items to multiple branches based on rules or an expression.
- Mode — Rules or Expression.
- Rules — value, operation, comparison value.
- Fallback Output — where unmatched items go.
Edit Fields (Set) Core
Create, rename, or modify fields on items.
- Mode — Manual Mapping or JSON.
- Fields to Set — Name, Type, Value.
- Options — Include Other Fields, Keep Only Set, Dot Notation.
Merge Core
Combines data from multiple inputs.
- Mode — Append, Combine, Choose Branch.
- Join Mode — Matching Columns, Combine All, Position.
- Output Type — List or Single Item.
Split In Batches Core
Processes items in smaller groups — useful for rate-limited APIs.
- Batch Size — number of items per batch.
- Options — Reset, No Items Left.
Wait Core
Pauses execution.
- Resume — Time Interval, Webhook, Specific Time.
- Amount & Unit — seconds, minutes, hours, days.
Execute Workflow Core
Calls another workflow — enables modular design.
- Source — Database, URL, ID.
- Mode — Wait or Run Once.
Item Lists Data
Split, aggregate, limit, deduplicate, sort, or summarize lists.
Filter Data
Keeps only items that match conditions (like IF but without branching).
NoOp Data
Does nothing — passes data through. Useful for organizing canvas flow.
Stop and Error Data
Stops the workflow and throws a custom error.
Trigger Nodes
Triggers are always the first node. They decide when a workflow runs.
| Trigger | When it fires | Key options |
|---|---|---|
| Manual Trigger | When you click "Execute Workflow" | None |
| Schedule Trigger | On a cron or interval schedule | Interval, Cron expression, Timezone |
| Webhook | On incoming HTTP request | Method, Path, Auth, Response Mode, CORS |
| App Trigger | On an app event (polling or webhook) | Credentials, Poll Times, Filters |
| Error Trigger | When another workflow fails | None — set as error workflow |
| Execute Workflow Trigger | When called by another workflow | Input schema |
Webhook Trigger — Response Modes
- On Received — respond immediately (async).
- Last Node — respond with the last node's output.
- Respond to Webhook Node — respond from a specific node.
- When Last Node Finishes — respond after execution completes.
Popular App Nodes
Google Sheets App
- Credentials — Google OAuth2 or Service Account.
- Resource — Spreadsheet, Sheet.
- Operation — Append, Read, Update, Clear, Delete, Create.
- Parameters — Spreadsheet ID, Sheet Name, Range, Data Mode, Columns.
- Options — Value Input Mode, Value Render Mode, Include Empty Cells, Use Header Row.
Slack App
- Credentials — OAuth2, Bot Token, Access Token.
- Resource — Message, Channel, User, File, Reaction.
- Operation — Send, Update, Delete, Get, Join, Leave.
- Parameters — Channel, Text, Blocks, Attachments.
- Options — Unfurl Links, Thread Reply, Ephemeral.
Gmail App
- Credentials — Gmail OAuth2.
- Resource — Message, Label, Draft, Thread.
- Operation — Send, Reply, Get, Get Many, Delete, Add Label.
- Parameters — To, Subject, Body, Attachments, Search Query.
- Options — CC, BCC, Reply-To, HTML.
Telegram App
- Credentials — Bot Token (from BotFather).
- Resource — Message, Chat, File, Callback.
- Operation — Send, Edit, Delete, Get, Answer Callback.
- Parameters — Chat ID, Text, Parse Mode, File, Reply Markup.
WhatsApp Business Cloud App
- Credentials — Access Token, Business Account ID, Phone Number ID.
- Resource — Message, Media.
- Operation — Send, Send Template, Send Media, Mark as Read.
- Parameters — Recipient, Message Type, Text, Media URL, Template Name.
Instagram App
- Credentials — Instagram OAuth2 or Facebook Graph API.
- Resource — Media, User, Comment.
- Operation — Get, Get Many, Publish, Reply, Delete.
Microsoft Outlook / Hotmail App
- Credentials — Microsoft OAuth2.
- Resource — Message, Calendar, Contact, Draft.
- Operation — Send, Get, Update, Delete, Reply, Create Event.
Databases
| Node | Credentials | Operations |
|---|---|---|
| Postgres | Host, port, db, user, password, SSL | Execute Query, Insert, Update, Delete, Select |
| MySQL | Host, port, db, user, password | Execute Query, Insert, Update, Delete, Select |
| MongoDB | Connection string | Insert, Update, Find, Delete |
| Redis | Host, port, password, db | Get, Set, Delete, Publish, Increment |
| Supabase | URL, Service Role Key | Create, Update, Get, Delete |
AI & LangChain Nodes
n8n groups AI nodes under the LangChain category. Most are sub-nodes that plug into an Agent or Chain.
Chat Models AI
Credentials: OpenAI API Key. Parameters: Model (gpt-4o, gpt-4.1), Temperature, Max Tokens, Top P, Frequency/Presence Penalty.
Credentials: Anthropic API Key. Parameters: Model (claude-3-5-sonnet), Temperature, Max Tokens, Top K.
Credentials: Google Gemini API Key or OAuth2. Parameters: Model, Temperature, Safety Settings.
Credentials: Ollama URL. Parameters: Model (llama3, mistral), Temperature, Repeat Penalty. Run local LLMs.
Credentials: Azure endpoint, deployment name, API version, key.
Other cloud LLM providers with similar parameters.
Memory Nodes AI
- Window Buffer Memory — keeps last N messages in memory.
- Postgres Chat Memory — persists conversation to Postgres.
- Redis Chat Memory — fast, TTL-based memory.
- MongoDB Chat Memory — persists to MongoDB.
- Zep / Motorhead / Xata — managed memory services.
Vector Stores AI
API key, environment, index name. Operations: Insert, Retrieve, Update, Delete.
URL + service key. Uses pgvector. RPC function for retrieval.
URL + API key. Collection name, top K, filter.
URL + API key. Class name, top K, filter.
Postgres with pgvector extension. Familiar SQL interface.
Open-source vector databases.
Embeddings AI
- OpenAI Embeddings — text-embedding-3-small / large.
- Cohere Embeddings — embed-english-v3.0.
- Hugging Face Embeddings — open-source models.
- Google Gemini / Azure OpenAI / Ollama / Mistral — provider-specific.
Text Splitters AI
- Recursive Character Text Splitter — chunk size, overlap, separators.
- Token Text Splitter — chunks by token count.
- Markdown / HTML / Code Splitters — format-aware chunking.
Document Loaders AI
- Default Data Loader — load from JSON input.
- GitHub / Google Drive / Notion / S3 / Confluence — load from sources.
- Web Document Loader — scrape URLs.
Agents AI
The AI Agent node is the centerpiece. It reasons, calls tools, and uses memory.
- Agent Types — Tools Agent, Conversational Agent, OpenAI Functions Agent, ReAct Agent, Plan and Execute Agent.
- Inputs — Prompt, Chat Model, Tools, Memory.
- Options — Max Iterations, Return Intermediate Steps, Enable Fallback.
- Output — Text, Tool Calls, Intermediate Steps.
Tools AI
Tools are functions the agent can call. Each is a sub-node.
- HTTP Request Tool — call any API.
- Code Tool — custom JS/Python function.
- Calculator — math.
- Wikipedia — knowledge lookup.
- SerpAPI — web search.
- Google Sheets / Slack / Gmail — app actions.
- Custom n8n Workflow Tool — call any workflow.
- Vector Store Retriever Tool — RAG retrieval.
Chains AI
- LLM Chain — prompt template + chat model.
- Conversation Chain — chat with memory.
- Retrieval QA Chain — RAG question answering.
- Summarization Chain — summarize long text.
- SQL Database Chain — natural language to SQL.
Web App Automation
n8n can serve as a lightweight backend for web apps using Webhook and HTTP Request nodes.
Pattern: Self-Contained CRUD App
- Use separate webhook paths for each operation:
/list,/create,/update,/delete. - Store data in Data Tables, Redis, or a database node.
- Serve HTML from a Webhook node with Response Mode = "Respond to Webhook".
Pattern: API Gateway
- Single webhook endpoint receives all requests.
- Switch node routes based on path or payload.
- Each branch calls a different service or sub-workflow.
Web App Security Checklist
- Enable webhook authentication (Basic, Header, JWT).
- Verify HMAC signatures for third-party webhooks.
- Implement rate limiting and replay protection.
- Validate and sanitize all input with a Code node.
- Use HTTPS and restrict CORS origins.
Cybersecurity & SOAR
n8n is a popular self-hosted SOAR (Security Orchestration, Automation, and Response) platform.
Phishing Analysis
Secret Leak Detection (SecretOps)
Vulnerability Management
- Schedule trigger pulls vulns from Tenable/Qualys/Snyk.
- Enrich with EPSS and CISA KEV data.
- Calculate priority score.
- Create Jira tickets and email reports.
SIEM Alert Enrichment
- Webhook receives SIEM alert.
- Extract IPs, hashes, domains.
- Query AbuseIPDB, VirusTotal, GreyNoise.
- Add context to TheHive case and notify analyst.
Security Best Practices for n8n
- Self-host inside your network — data never leaves.
- Use RBAC, SSO/SAML, and 2FA for n8n access.
- Store credentials in n8n's encrypted credential store or external secrets manager.
- Implement human-in-the-loop for destructive actions (revoke, block, delete).
- Log all executions to a SIEM for audit.
HRM Systems
n8n acts as the orchestration layer connecting HRIS, payroll, IT, and communication tools.
Core HR Data Sync
- Schedule trigger polls HRIS (BambooHR, Workday, Gusto) daily.
- Code node detects new hires, departures, and profile changes.
- Propagate changes to Slack, Teams, Coda, and Google Workspace.
Recruitment Pipeline
Onboarding / Offboarding
- On new hire: create accounts (Google, Slack, Jira), send welcome email, schedule training.
- On termination: revoke access across all systems, generate compliance report, archive data.
Payroll & Leave
- Fetch attendance, calculate salary with AI, generate PDF payslips, email employees.
- Leave request via form → policy check → manager approval in Slack → update tracker.
Engagement & Retention
- Sentiment analysis on Slack/survey text.
- Attrition risk flags sent to managers.
- Automated performance review cycles.
Enterprise Patterns
PagerDuty → enrich with CMDB → create Jira → notify Slack → log to Postgres.
HRIS webhook → create accounts → send welcome → schedule training → notify manager.
Email trigger → OCR → AI parse → validate PO → enter ERP → route for approval.
Form webhook → Clearbit/Apollo → create CRM lead → assign rep → Slack notify.
Zendesk webhook → AI classify/prioritize → route → auto-respond if simple.
Schedule → extract from APIs → transform with Code → load to Snowflake/BigQuery.
Slack command → AI Agent → vector store retriever → LLM answer.
Webhook → Slack approval → Wait node → proceed or reject → log decision.
Enterprise-Grade Capabilities
| Area | n8n Capability |
|---|---|
| Deployment | Self-hosted, Docker, Kubernetes, queue mode with Redis workers |
| Security | SSO/SAML, LDAP, RBAC, 2FA, audit logs, encrypted credentials |
| Governance | Git version control, environments (dev/staging/prod), approval workflows |
| Scalability | Concurrency, rate limiting, batching, sub-workflows, horizontal scaling |
| Monitoring | Prometheus, Grafana, error workflows, execution data pruning |
| Compliance | GDPR, HIPAA, SOC2, data residency, encryption at rest/transit |
Trading & Markets
n8n has native market data nodes and can connect to any broker via HTTP Request.
Native Market Data Nodes
| Node | Data | Key Parameters |
|---|---|---|
| Alpha Vantage | Stocks, Forex, Crypto, Indicators | Symbol, Interval, Function, Output Size |
| CoinGecko | Crypto markets | Coin ID, Currency, Days |
| Marketstack | End-of-day, Intraday | Symbol, Date, Interval |
| Frankfurter | Currency exchange rates | Base, Symbols, Amount, Date |
Live Trading via HTTP Request
- Brokers — Binance, Coinbase, Kraken, Alpaca, Interactive Brokers, OANDA, MetaTrader.
- Authentication — API Key/Secret, OAuth2, JWT.
- Order body — symbol, side, quantity, price, type.
- Triggers — Schedule (cron), Webhook (TradingView alerts), Manual.
Community Nodes
n8n-nodes-ccxt— unified crypto exchange API.n8n-nodes-binance— Binance-specific.n8n-nodes-alpaca— Alpaca-specific.
Example Trading Workflow
Expressions — Advanced
Expressions use {{ }} syntax. You can also use ={{ }} for explicit expression mode.
Core Variables & Helpers
| Expression | Description |
|---|---|
$json | JSON data of the current item |
$json.fieldName | Access a field |
$json['body']['city'] | Bracket notation for nested fields |
$binary | Binary data of the current item |
$("NodeName").first() | First item from a previous node |
$("NodeName").all() | All items from a previous node |
$("NodeName").last() | Last item from a previous node |
$("NodeName").item | Linked item (item linking) |
$now | Current date and time |
$today | Today's date |
$now.toFormat('yyyy-MM-dd') | Format current date |
$if(condition, "true", "false") | Conditional helper |
$ifEmpty(value, defaultValue) | Fallback if value is empty |
$env.MY_VAR | Environment variable |
$execution.id | Current execution ID |
$workflow.name | Workflow name |
Advanced Patterns
IIFE (Immediately Invoked Function Expression)
For multi-statement logic in an expression, wrap it in an IIFE:
{{ (() => {
let end = DateTime.fromISO('2026-03-13');
let start = DateTime.fromISO('2026-02-13');
let diff = end.diff(start, 'months');
return diff.toObject();
})() }}
Conditional Content
{{ $json.status === 'active' ? '✅ Active' : '❌ Inactive' }}
Array Methods
{{ $json.items.map(i => i.id) }}
{{ $json.items.filter(i => i.active).length }}
{{ $json.items.reduce((sum, i) => sum + i.amount, 0) }}
Expressions in Credentials
You can use expressions in credential fields. n8n evaluates them within the context of the current execution. Each execution has its own data context, so different executions don't share data.
Error Handling
Node-Level Options
- Retry On Fail — automatic retries with wait interval (max 3 by default).
- Continue On Fail — workflow keeps running, error is attached to the item.
- On Error — Stop Workflow, Continue, or Continue with Error Output.
- Timeout — kill node after N milliseconds.
Error Workflow Setup
- Create a new workflow with an Error Trigger as the first node.
- Name it (e.g., "Error Handler") and save.
- In the workflow you want to monitor: Options → Settings → Error workflow → select the error workflow.
- When the monitored workflow fails, the error workflow runs automatically.
Error Data Structure
[
{
"execution": {
"id": "231",
"url": "https://n8n.example.com/execution/231",
"retryOf": "34",
"error": {
"message": "Example Error Message",
"stack": "Stacktrace"
},
"lastNodeExecuted": "Node With Error",
"mode": "manual"
},
"workflow": {
"id": "1",
"name": "Example Workflow"
}
}
]
- The Error Trigger only runs when an automatic workflow errors. You can't test error workflows manually.
- If a workflow contains an Error Trigger node, by default it uses itself as the error workflow.
- The Error Trigger workflow does not need to be published/activated.
Error Workflow Patterns
Resilience Framework
- Step 1 — Map the happy path and identify failure points.
- Step 2 — Use Error Workflows or Error Triggers globally.
- Step 3 — Use HTTP Request node's built-in retry options (3–5 retries with exponential backoff).
- Step 4 — Implement conditional branching for expected errors.
Sub-Workflows (Modular Design)
Sub-workflows let you call one workflow from another, enabling modular, microservice-like design. They also help when workflows grow large enough to encounter memory issues.
Key Benefits
- Reusability — call a validated sub-workflow from multiple parent workflows.
- Isolation — test sub-workflow logic independently.
- Memory efficiency — sub-workflow holds data for one batch, then frees memory.
- Scoped credentials — keep sensitive integrations in specific workflows.
- No execution limit impact — sub-workflow executions don't count toward plan limits.
Setup
- Create a new workflow (the sub-workflow).
- Add an Execute Sub-workflow Trigger node (aka "When Executed by Another Workflow").
- Set Input data mode:
- Define using fields below — define individual input names and types.
- Define using JSON example — provide an example JSON object.
- Accept all data — accept any input unconditionally.
- Build the sub-workflow logic.
- Save. The sub-workflow must not contain errors.
- In the parent workflow, use the Execute Workflow node → select the sub-workflow.
Input Mode: all vs each
| Mode | Sub-workflow runs | Items per run |
|---|---|---|
all (default) | Once | All N items, flowing through nodes per-item as usual |
each | N times | Exactly one item per run |
Pattern: Batch Processing with Sub-Workflows
Sub-Workflow Conversion
n8n can automatically convert part of a workflow into a sub-workflow. Select nodes → right-click → Sub-workflow conversion. Expressions referencing other nodes are automatically updated and added as parameters in the Execute Sub-workflow Trigger node.
Credential Management
Credential Overwrites
Credential overwrites let you set credential data globally. This data isn't visible to users, but n8n uses it automatically in the background — for example, to enable OAuth login using a "Connect" button without exposing client secrets.
Using the REST API (Recommended)
- Set the endpoint path:
export CREDENTIALS_OVERWRITE_ENDPOINT=send-credentials - Optionally set an auth token:
export CREDENTIALS_OVERWRITE_ENDPOINT_AUTH_TOKEN=secure-token - Prepare a JSON file with credentials:
{ "asanaOAuth2Api": { "clientId": "<id>", "clientSecret": "<secret>" }, "githubOAuth2Api": { "clientId": "<id>", "clientSecret": "<secret>" } } - Send the file:
curl -H "Content-Type: application/json" \ --data @oauth-credentials.json \ http://localhost:5678/send-credentials
CREDENTIALS_OVERWRITE_DATA) is not recommended — environment variables aren't protected in n8n, so data can leak to users. Use the REST API endpoint instead.
Credential Inheritance
Credentials can extend other credentials. For example, googleSheetsOAuth2Api extends googleOAuth2Api. You can set parameters on the parent and all child credentials will use them.
Security Checklist
- Never hardcode secrets — use credentials or environment variables.
- Use RBAC and least-privilege API keys.
- Enable and rotate the encryption key (
N8N_ENCRYPTION_KEY) — all instances must share the same key. - Use separate API keys for different environments.
- Regularly rotate credentials and monitor usage for anomalies.
- Use 2FA for admin and editor accounts.
- Place n8n behind an identity provider (Keycloak, Okta, etc.).
Community Nodes
The n8n community has built thousands of custom nodes. As of early 2026, there are 5,834+ community nodes indexed, growing at ~18 new nodes per day.
Top Community Nodes by Monthly Downloads
| Node | Description | Monthly Downloads |
|---|---|---|
n8n-nodes-evolution-api | WhatsApp automation via Evolution API | 6,614,815 |
n8n-nodes-chatwoot | ChatWoot integration for customer support | 615,402 |
n8n-nodes-zapi | Z-API WhatsApp integration | 149,780 |
n8n-nodes-imap | Connect to IMAP email servers | 105,656 |
@devlikeapro/n8n-nodes-waha | WAHA WhatsApp HTTP API | 70,437 |
Categories
- Communication & Messaging — WhatsApp, ChatWoot, Telegram variants.
- Document & Content Generation — PDF, DOCX, report generators.
- Browser Automation & Web Scraping — Puppeteer, Playwright wrappers.
- Data Processing & Validation — CSV streaming, JSON validation.
- API & Cloud Integrations — niche SaaS and cloud providers.
- AI, LLM & Voice — additional model providers, voice tools.
- File & PDF Manipulation — advanced file operations.
N8N_COMMUNITY_PACKAGES_ENABLED=true.
Code Node Best Practices
Mode Selection
- Run Once for All Items — recommended for ~95% of use cases. Access all items via
$input.all(),$input.first(), or$input.item. - Run Once for Each Item — use when each item needs independent processing.
Data Access Patterns
// Get all items
const items = $input.all();
// Get first item
const first = $input.first().json;
// Get current item (in each-item mode)
const current = $input.item.json;
// Access from a specific node
const httpData = $("HTTP Request").first().json;
// Return proper n8n format
return items.map(item => ({
json: {
...item.json,
processed: true
}
}));
Common Patterns
Filter & Transform
return $input.all()
.filter(item => item.json.age >= 18)
.map(item => ({
json: {
name: item.json.name,
email: item.json.email.toLowerCase(),
bonus: item.json.salary * 0.1
}
}));
Aggregate & Summarize
const items = $input.all();
const total = items.reduce((sum, i) => sum + i.json.amount, 0);
const avg = total / items.length;
return [{
json: {
total,
average: avg,
count: items.length
}
}];
Multi-Source Aggregation
const sourceA = $("Node A").all().map(i => i.json);
const sourceB = $("Node B").all().map(i => i.json);
const merged = sourceA.map(a => ({
...a,
extra: sourceB.find(b => b.id === a.id)?.value || null
}));
return merged.map(m => ({ json: m }));
- Empty code / missing return (38% of failures) — always return an array of
{ json: ... }objects. - Expression syntax confusion (8%) — don't mix
{{ }}inside Code node; use JavaScript directly. - Incorrect return wrapper (5%) — must be
[{ json: data }], not{ json: data }. - Unmatched expression brackets (6%) — double-check
{{ }}pairing in expression fields.
Performance & Memory Optimization
Memory Limits (n8n Cloud)
| Plan | RAM | CPU |
|---|---|---|
| Trial / Starter | 320 MiB | 10 millicore burstable |
| Pro-1 (10k executions) | 640 MiB | 20 millicore burstable |
| Pro-2 (50k executions) | 1280 MiB | 80 millicore burstable |
| Enterprise | 4096 MiB | 80 millicore burstable |
n8n itself uses ~180 MiB RAM just to run. UI interactions also consume memory.
How to Reduce Memory Consumption
- Split data into chunks — process 200 rows per execution instead of 10,000.
- Avoid the Code node where possible — use native nodes for simple transformations.
- Avoid manual executions when processing large data — they hold all data in memory.
- Use sub-workflows — sub-workflow holds data for one batch, then frees memory.
- Stop saving successful executions — once a workflow is past testing, disable execution data storage for successes.
- Prune execution data — configure
EXECUTIONS_DATA_PRUNE=trueand set max age/count.
Pattern: Batch Processing
Pagination vs Loops
- Use the HTTP Request node's Pagination option instead of building loops.
- Configure: "Response Contains Next URL", next URL field, request interval, max requests.
- This is more memory-efficient than fetching all pages into a single array.
Queue Mode & Scaling
Queue mode provides the best scalability for n8n. It separates the main instance (which receives triggers) from worker instances (which execute workflows).
Architecture
How It Works
- The main instance handles timers and webhook calls, generating (but not running) executions.
- It passes the execution ID to Redis, which maintains the queue.
- A worker picks up the message from Redis.
- The worker uses the execution ID to get workflow info from the database.
- After completion, the worker writes results to the database and posts to Redis that the execution finished.
- Redis notifies the main instance.
Key Configuration
# Enable queue mode (required on main + all workers)
EXECUTIONS_MODE=queue
# Redis connection
QUEUE_BULL_REDIS_HOST=redis
QUEUE_BULL_REDIS_PORT=6379
# Encryption key (must be identical across all instances)
N8N_ENCRYPTION_KEY=<main_instance_key>
# Database (Postgres recommended over SQLite)
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=postgres
DB_POSTGRESDB_DATABASE=n8n
Scaling Workers
# Scale to 5 workers
docker compose up -d --scale n8n-worker=5
# Scale down to 2 workers
docker compose up -d --scale n8n-worker=2
Worker Sizing Guidelines
| CPU | RAM | Concurrent Executions |
|---|---|---|
| 2 cores | 4 GB | 5–8 |
| 4 cores | 8 GB | 10–15 |
| 8 cores | 16 GB | 20–30 |
| 16+ cores | 32+ GB | 40+ |
- Don't use SQLite — use Postgres or MySQL for production queue mode.
- All workers need the same
N8N_ENCRYPTION_KEYto access stored credentials. - Binary data storage in filesystem is not supported in queue mode — use S3 external storage if you need binary persistence.
Troubleshooting
Common Issues
| Issue | Likely Cause | Fix |
|---|---|---|
| "JSON Output contains invalid JSON" | Expression mode vs JSON mode mismatch | Switch field to expression mode or fix JSON syntax |
| Code node returns nothing | Missing return or wrong format | Return [{ json: data }] |
| Memory crash | Large dataset in one execution | Use Split In Batches + sub-workflows |
| Webhook not firing | Workflow not activated | Publish/activate the workflow |
| Credential errors on workers | Encryption key mismatch | Set same N8N_ENCRYPTION_KEY on all instances |
| Error workflow not running | Manual execution or trigger error | Error Trigger only runs on automatic workflow errors |
| Sub-workflow won't trigger | Errors in sub-workflow | Fix errors — parent can't call a broken sub-workflow |
| Expression returns undefined | Field name wrong or missing | Use $json['field'] bracket notation, check input |
| Queue mode not working | Using SQLite | Switch to Postgres/MySQL |
Debugging Tips
- Use the Execution list to see input/output for each node.
- Click a node to inspect its input and output data panels.
- Use
console.log()in the Code node to debug. - Run individual nodes with the "Execute Node" button.
- Use pin data to freeze the output of a node during development.
- Check the browser console for client-side errors.
Best Practices
Workflow Design
- Keep workflows small and modular — use sub-workflows.
- Name nodes clearly (not "HTTP Request1").
- Add Notes to complex nodes.
- Use Edit Fields (Set) early to normalize data shape.
- Handle errors at both node and workflow level.
- Use item linking to preserve data relationships across nodes.
Security
- Never hardcode secrets — use credentials or environment variables.
- Use RBAC and least-privilege API keys.
- Self-host for sensitive data.
- Enable 2FA and SSO.
- Regularly rotate credentials and encryption keys.
- Use credential overwrites for managed OAuth.
Performance
- Use Split In Batches for large datasets.
- Enable pagination on HTTP Request instead of loops.
- Use Queue Mode for high concurrency.
- Prune execution data regularly.
- Cache frequently used data in Redis.
- Use sub-workflows to free memory between batches.
Maintenance
- Version-control workflows via Git.
- Use separate environments (dev/staging/prod).
- Monitor with Prometheus + Grafana.
- Document workflows and credentials ownership.
- Test in dev before promoting to prod.
- Set up error workflows for all production workflows.
Glossary
| Term | Definition |
|---|---|
| Item | A single unit of data (JSON object) passed between nodes. |
| Node | A single step in a workflow that performs an action. |
| Trigger | The first node in a workflow that decides when it runs. |
| Execution | A single run of a workflow. |
| Expression | Dynamic value written in {{ }} syntax. |
| Credential | Stored authentication for external services. |
| Sub-workflow | A workflow called by another workflow. |
| Error Workflow | A workflow that runs when another workflow fails. |
| Queue Mode | Scalable execution mode with main + worker instances. |
| Item Linking | Preserving the relationship between items across nodes. |
| Pagination | Automatically fetching multiple pages of API results. |
| RAG | Retrieval-Augmented Generation — using vector stores to ground LLM answers. |
| Vector Store | A database optimized for similarity search on embeddings. |
| Embedding | A numerical vector representation of text. |
| Agent | An AI node that reasons, calls tools, and uses memory. |
Quick Reference
Most-Used Nodes at a Glance
| Node | Category | Purpose |
|---|---|---|
| HTTP Request | Core | Universal API connector |
| Code | Core | Custom JS/Python logic |
| IF | Core | Conditional branching |
| Switch | Core | Multi-branch routing |
| Edit Fields (Set) | Core | Data shaping |
| Merge | Core | Combine data streams |
| Split In Batches | Core | Rate-limited processing |
| Wait | Core | Delay execution |
| Execute Workflow | Core | Call sub-workflow |
| Webhook | Trigger | HTTP entry point |
| Schedule Trigger | Trigger | Cron/interval |
| Error Trigger | Trigger | Error workflow entry |
| Google Sheets | App | Spreadsheet CRUD |
| Slack | App | Messaging |
| Gmail | App | |
| Telegram | App | Bot messaging |
| WhatsApp Business | App | WhatsApp messaging |
| Postgres / MySQL | Database | SQL operations |
| OpenAI Chat Model | AI | LLM |
| AI Agent | AI | Autonomous reasoning |
| Pinecone / Supabase Vector | AI | Vector storage |
Common Workflow Patterns
Receive HTTP request, process data, send response back. Foundation of web app automation.
Periodic data sync from APIs into a database or sheet.
Event fires, AI analyzes, action taken (e.g., classify, route, respond).
Request → Slack approval → Wait → proceed/reject → log.
Load → Split → Embed → Store → Query → Retrieve → LLM answer.
Split In Batches → sub-workflow → return small result. Memory-efficient.
Error Trigger → format → log → alert → create ticket.
Main → Redis → Workers → Postgres. Horizontal scaling.
Node Categories
| Category | Examples |
|---|---|
| Core Logic | IF, Switch, Merge, Split In Batches, Wait, Code |
| Data | Set, Item Lists, Filter, Sort, Aggregate |
| Triggers | Webhook, Schedule, Manual, App Triggers, Error Trigger |
| Communication | Slack, Gmail, Telegram, Discord, Microsoft Teams, WhatsApp |
| Productivity | Google Sheets, Notion, Airtable, Trello, Asana, ClickUp |
| CRM | Salesforce, HubSpot, Pipedrive, Zoho |
| Databases | Postgres, MySQL, MongoDB, Redis, Supabase, Elasticsearch |
| Cloud Storage | S3, Google Drive, Dropbox, OneDrive, Box |
| AI / LangChain | Chat Models, Agents, Memory, Tools, Vector Stores, Embeddings |
| DevOps | GitHub, GitLab, Jira, SSH, Execute Command |
| Finance | Stripe, QuickBooks, Xero, Plaid |
| Market Data | Alpha Vantage, CoinGecko, Marketstack, Frankfurter |
Learning Path
- Basics — Manual Trigger → Set → HTTP Request → Slack.
- Data handling — IF, Switch, Merge, Code, Item Lists.
- Triggers — Webhook, Schedule, App Triggers.
- Error handling — Retry, Continue On Fail, Error Trigger workflow.
- Modularity — Sub-workflows with Execute Workflow.
- Expressions — Advanced syntax, IIFE, array methods.
- Performance — Split In Batches, pagination, memory optimization.
- AI — Chat Model → AI Agent → Tools → Memory → Vector Store.
- Production — Queue mode, monitoring, RBAC, Git sync, credential overwrites.
n8n Extended Educational Reference · Compiled from official docs, community templates, and real-world usage patterns.
Always check the official n8n documentation for the latest node versions and features.