Use this when n8n workflows branch with IF and Switch nodes.
Branching · n8n
Branching in n8n uses the IF and Switch nodes to send items down different paths based on conditions, merging them later with the Merge node if needed.
1. Branching with IF and Switch nodes.
2. Always handle the else/fallback path.
3. Merge branches carefully (wait modes).
4. Test each path.
5. Keep logic readable.
items → IF/Switch → branches → merge
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The primary procedure is: Execute the workflow with pinned fixture data; inspect the Branch/If node input and each output branch in the execution view; verify only the intended downstream target changed. Exercise failure-oriented cases such as null/missing fields, string-versus-number coercion, empty item sets, multiple matching rules and expression errors so the test covers failure cases, not only the happy path.
Step 2 Common mistakes Narrow the fault
- IF branches without a default path.
Step 3 Where it fails Narrow the fault
Failure analysis for n8n → Branching should follow the path through the components: trigger/input acquisition → expression evaluation → branch selection → downstream node execution → external target state. Tests should include edge cases such as null/missing fields, string-versus-number coercion, empty item sets, multiple matching rules and expression errors.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- IF and Switch nodes branch workflows.
- Merge rejoins branches.
- Test each path.
- IF/Switch nodes — branching
- Default/fallback branch — unexpected values
- Merge node behaviour — joining
ReferenceWhy it matters1 section · depth on demand
In depth
Branching in n8n routes items down different paths with the IF node (true/false) or the Switch node (multiple outputs by rule). Items are evaluated individually, so one input list can be split across branches.
| Node | Use |
|---|---|
| IF | Two-way split on a condition |
| Switch | Many outputs by value or rule |
| Merge | Join branches back together |
| Filter | Drop items that do not match |
Be careful when merging: the Merge node's mode (append, combine by key, wait for both) decides whether data from both branches lines up as intended.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Branching in n8n is owned at runtime by the n8n execution engine evaluating an If/Switch decision for one workflow execution. The durable intent is workflow JSON containing node parameters, expressions and outgoing connections. Reliable automation must carry stable identity across the path: workflow ID/version, execution ID, node ID and credential bindings. The consumer-visible target is the downstream branch nodes and any external systems they mutate. The key invariants are exact input item set, expression data types, comparison operators, branch ordering and item routing semantics.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Store and review workflow JSON containing node parameters, expressions and outgoing connections; pin or at least record implementation/model versions and keep environment-specific identity outside reusable logic where possible. The stable identity contract is workflow ID/version, execution ID, node ID and credential bindings.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in n8n > Branching. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.if/ · confidence 94%Quick lookup tables
n8n → Branching · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for n8n → Branching.
| Layer | n8n → Branching operational reference |
|---|---|
| Runtime/ownership | n8n workflow branching · the n8n execution engine evaluating an If/Switch decision for one workflow execution |
| Persistent intent | workflow JSON containing node parameters, expressions and outgoing connections |
| Verification | Execute the workflow with pinned fixture data; inspect the Branch/If node input and each output branch in the execution view; verify only the intended downstream target changed. |
| Expected interpretation | Each fixture item follows the branch implied by the evaluated n8n expression, nonmatching items do not reach protected side effects, and downstream target state matches the selected path. |
| Recovery boundary | preserve execution data and node input/output, correct the first wrong expression or route, then replay a bounded fixture and verify the downstream target |
Deep reference
Healthy vs suspicious evidence
Output interpretation
At minimum retain workflow ID, execution ID, node ID, input item index, evaluated fields, rule/operator, chosen output index, downstream node IDs, run status and external object IDs. The useful output makes ambiguity visible, links to the target identity from workflow ID/version, execution ID, node ID and credential bindings, and provides enough context to safely decide whether a retry is permitted.