n8n IF Node: Adding Conditional Logic to Your Workflows
Every workflow eventually needs to make a decision. The IF node is n8n’s mechanism for conditional branching — it routes each incoming item down one of two paths based on whether a condition evaluates to true or false.
How the IF Node Works
The IF node evaluates a condition (or set of conditions) against each item it receives. Items that satisfy the condition exit through the True output. Items that do not satisfy it exit through the False output. Each output can connect to a different chain of nodes.
You can configure each output independently. The True branch might write to a database while the False branch sends a notification. Or the False branch might connect to nothing at all — items that fail the condition are silently dropped.
Building Conditions
Each condition compares a value against a comparator. The value is typically a field from the incoming item ($json.status, $json.amount) or a workflow expression. The comparator defines the comparison type.
String comparators:
equals/not equals— exact matchcontains/does not contain— substring checkstarts with/ends withis empty/is not empty— useful for checking whether a field exists and has a valueregex— full regular expression match
Number comparators:
equals,not equalslarger than,smaller than,larger than or equal,smaller than or equal
Boolean comparators:
is true,is false
DateTime comparators:
after,before,is same— compare dates as ISO strings or timestamps
Combining Conditions
A single IF node can evaluate multiple conditions. The Combine setting controls how they relate:
- AND — all conditions must be true for the item to route true
- OR — at least one condition must be true
Example: route a CRM contact to a high-priority queue if status equals "trial" AND plan equals "enterprise". Both conditions must match.
You cannot mix AND and OR logic within a single IF node — for complex boolean logic (A AND B) OR C, chain multiple IF nodes or use a Code node.
Common Patterns
Null/empty check before processing:
Field: {{ $json.email }}
Condition: is not empty
True branch: process the record. False branch: log the missing email or send an alert.
Status-based routing:
Field: {{ $json.orderStatus }}
Condition: equals "paid"
True branch: fulfill the order. False branch: queue for manual review.
Threshold check:
Field: {{ $json.score }}
Condition: larger than or equal to 7
True branch: trigger high-priority follow-up. False branch: add to nurture sequence.
Type check: Sometimes you need to check whether a field is a number, string, or object before operating on it. Use a Code node upstream to type-check and add a flag field, then use IF to branch on that flag.
The Switch Node for Multiple Branches
The IF node handles two branches. When you need three or more branches, use the Switch node instead.
Switch routes items based on a single value matching one of several cases:
- Case 1:
status = "active"→ billing update branch - Case 2:
status = "trial"→ conversion tracking branch - Case 3:
status = "cancelled"→ churn analysis branch - Fallback: catch-all for any value not matched above
Switch is cleaner than chaining multiple IF nodes when you are routing on the same field with different values.
After the Branch: Merging Back
After branching, you often need to bring the two paths back together — for example, to log both outcomes in the same place.
Use the Merge node to rejoin branches. The most common merge mode for IF branches is Merge by Position (combine item at index 0 from True with item at index 0 from False) or Pass-through (let all items through regardless of which branch they came from).
One subtlety: if one branch produces no items (all items went True, leaving the False branch empty), the Merge node will wait indefinitely for items from the empty branch. Handle this by connecting both IF outputs to the merge node and ensuring both paths always produce an item — or by skipping the merge if you do not need to rejoin.
Expressions in Conditions
Conditions support full n8n expressions. This means you can compare computed values, not just raw field values:
{{ $json.price * $json.quantity }}— compare the product, not just one field{{ new Date($json.dueDate) < new Date() }}— check if a date is in the past{{ $json.tags.includes("urgent") }}— check array membership
For complex conditions that are hard to express in the GUI, evaluate the condition in a Code node upstream, set a boolean result field, then use IF to branch on {{ $json.conditionResult }} equals true.
Debugging IF Nodes
When items are unexpectedly routing to the wrong branch, check the actual type of the value being compared. A common issue: a numeric field stored as a string ("7" instead of 7) causes numeric comparators to behave unexpectedly. Use the Number type setting in the IF condition, or convert the field upstream.
The execution log shows which branch each item took. Click the IF node after a test run to see exactly how many items exited through True vs False and what their values looked like at evaluation time.
The IF node, combined with the Switch node and the Merge node, gives you the full conditional logic toolkit you need to build workflows that handle the messy variation of real-world data.