The n8n IF and Switch Nodes: Master Conditional Logic in Your Workflows (2025)
Every non-trivial workflow eventually needs to make a decision: if this, do that; otherwise, do something else. In n8n, that’s the job of the IF and Switch nodes. Get them right and your workflows stay readable; get them wrong and you end up with a tangle of duplicated branches.
The IF node: two-way branching
The IF node evaluates one or more conditions and sends each item down either the true or false output. Use it when the answer is binary.
Condition: {{ $json.score }} is greater than 70
→ true output: notify sales
→ false output: add to nurture listYou can combine multiple conditions with AND / OR. In recent n8n versions the condition builder is strongly typed — pick the data type (string, number, boolean, dateTime) so comparisons behave predictably.
The Switch node: multi-way branching
When you have more than two paths, don’t chain IF nodes — use Switch. It routes items to one of many outputs based on rules or an expression.
- Rules mode: define a condition per output (e.g. plan = free → output 0, plan = pro → output 1, plan = enterprise → output 2).
- Expression mode: return an output index directly from an expression.
- Fallback output: catch anything that matches no rule so items never silently vanish.
⚡ Skip the build: AI Lead Qualifier — Score + Enrich Every Lead Automatically
Route hot, warm, and cold leads down different paths automatically — branching logic done right.
IF vs Switch — which to reach for
| Situation | Use |
|---|---|
| Yes/no decision | IF |
| 3+ distinct categories | Switch |
| Route by status/tier/type | Switch |
| Simple guard clause | IF |
Patterns that keep branches clean
1. Merge back when paths reconverge
If branches do different work but then continue together, use a Merge node so you don’t duplicate the downstream nodes.
2. Always set a fallback
An unmatched Switch item with no fallback just disappears — a silent bug. Wire the fallback to a logging or alert step.
3. Filter vs IF
If you only care about items that pass and want to drop the rest entirely, the Filter node is cleaner than an IF with an empty false branch.
4. Keep conditions readable
Push complex logic into a Set or Code node that computes a clear field (e.g. tier), then branch on that single field.
Common mistakes
- Type mismatches: comparing a string “70” to number 70 fails — set the correct data type.
- Empty branches: a false output wired to nothing is fine, but document it so it doesn’t look like an oversight.
- IF chains: three or more stacked IF nodes is a signal you wanted Switch.
FAQ
Can Switch handle ranges? Yes — use greater/less-than rules, ordered from most to least specific.
Do both nodes process items individually? Yes, each incoming item is evaluated and routed on its own.
Ready to automate this?
Don’t rebuild it from scratch. AI Lead Qualifier — Score + Enrich Every Lead Automatically is a production-ready n8n workflow you can import in minutes — credentials in, activate, done.