Skip to content
MoveWorkflows

n8n If node: conditions and examples

Updated 2026-10-21 · 5 min read

In short
  • The If node has two outputs: matching items go to true, the rest to false.
  • It checks each item on its own, so one run can use both outputs.
  • Most problems are data types, such as a number that arrives as the string "10".
Check my export – free reportRuns in your browser. Nothing is uploaded.
On this page · 7 sections
  1. How the If node evaluates items
  2. Adding conditions
  3. Examples
  4. Type pitfalls
  5. If, Switch, Filter or code?
  6. Joining branches again
  7. From Pipedream If/Else

The n8n If node splits a workflow into two paths. You define the conditions. Items that match leave through the true output, the rest through false.

Most problems people have with it come from data types, not from logic. This page lists every comparison and shows how to combine them. It also covers the cases where Switch or Filter is the better choice.

How the If node evaluates items

The If node checks each item separately. Say 10 items come in and 3 have status = "paid". Then three items leave on true and seven on false, in the same run. Both outputs can fire, and the nodes on each branch run for their own items.

An if statement in code runs once. The If node does not. Sometimes you need one decision for the whole batch, for example "is the list empty?". Then aggregate the items first, or use a Code node that returns one item.

Adding conditions

Each condition has three parts:

  1. A value, usually an expression like {{ $json.status }}.
  2. A data type with an operator.
  3. A value to compare against.

Select Add condition to add more.

Comparisons by data type

These are the operators per type, from the If node docs:

Type Operators
String exists, does not exist, is empty, is not empty, is equal to, is not equal to, contains, does not contain, starts with, does not start with, ends with, does not end with, matches regex, does not match regex
Number exists, does not exist, is empty, is not empty, is equal to, is not equal to, is greater than, is less than, is greater than or equal to, is less than or equal to
Date & Time exists, does not exist, is empty, is not empty, is equal to, is not equal to, is after, is before, is after or equal to, is before or equal to
Boolean exists, does not exist, is empty, is not empty, is true, is false, is equal to, is not equal to
Array exists, does not exist, is empty, is not empty, contains, does not contain, length equal to / not equal to / greater than / less than / greater than or equal to / less than or equal to
Object exists, does not exist, is empty, is not empty

The Switch node uses the same list. Anything you learn here carries over.

AND and OR

With two or more conditions, the dropdown between them sets the logic:

  • AND: the item must meet all conditions.
  • OR: the item must meet at least one.

The condition builder applies one combinator to all conditions. So you can't mix AND and OR in one node. The Filter docs say the same for its identical builder.

For (A AND B) OR C, you have two options. Chain two If nodes. Or write the whole test as one Boolean condition:

{{ ($json.country === 'DE' && $json.total > 100) || $json.vip === true }}

Set the type to Boolean and the operator to is true.

Examples

Route paid orders

  • Value: {{ $json.status }}
  • String > is equal to
  • paid

Skip items without an email

  • Value: {{ $json.email }}
  • String > is not empty

Items with an empty or missing email go to false. Leave the false output unconnected, and they stop there.

Only recent records

  • Value: {{ $json.createdAt }}
  • Date & Time > is after
  • {{ $now.minus({ days: 7 }) }}

Check an HTTP status code

Put this after an HTTP Request node. In that node, turn on Never Error and Include Response Headers and Status.

  • Value: {{ $json.statusCode }}
  • Number > is equal to
  • 404

The true branch creates the record. The false branch updates it.

Webhook validation

Put this right after a Webhook node:

  • {{ $json.body.email }} String > matches regex ^[^@\s]+@[^@\s]+$
  • AND {{ $json.body.amount }} Number > is greater than 0

The false branch goes to a Respond to Webhook node with status 400.

Type pitfalls

When someone reports "the If node is wrong", it is usually a type mismatch.

Problem Example Fix
Number arrives as text Query parameter "10" compared with Number > is greater than 9 {{ Number($json.query.limit) }}
Boolean arrives as text "true" from a form Compare as String is equal to true, or convert
Date as text "21/10/2026" Parse it first with the Date & Time node or Luxon in an expression
Field missing vs empty undefined vs "" Use exists for missing, is empty for empty
Upper and lower case "Paid" vs "paid" Lowercase in the expression: {{ $json.status.toLowerCase() }}

The Switch and Filter docs describe a Less Strict Type Validation option. With it, n8n tries to convert values to the operator's type. Converting yourself in the expression is easier to debug.

If, Switch, Filter or code?

Need Use
Two paths If
Three or more paths Switch
Drop items that don't match, keep one path Filter
Complex condition used once One Boolean condition with an expression
Condition that needs several lookups or loops Code node returning a flag, then If

Joining branches again

After an If node, the two branches are separate. Should they continue into the same nodes? Then connect both outputs to the next node, or put a Merge node in between.

Workflows that use the current (v1) execution order run only the branch that received items. The legacy v0 order could run both branches when a Merge node followed an If node. The docs keep a note about it for old workflows.

From Pipedream If/Else

Pipedream's If/Else operator maps to the n8n If node. Pipedream marks it beta in its docs. Pipedream's Filter operator maps to the n8n Filter node.

In a Pipedream export, the steps inside if/else branches sit in a separate deployments field. A naive conversion drops them. Our converter reads that field and rebuilds branches as If and Switch nodes where it can. It still marks every workflow with branches for manual review, because branch conditions need a check by hand. Details: Pipedream control flow to n8n.

See which of your workflows use branches with the free report, or test a single code step with the Code node compatibility check. The report and 1 workflow are free. Full export: $3 per workflow, $1 each after 50, $19 minimum, one-off.

Not affiliated with Pipedream or n8n.

FAQ

How many outputs does the n8n If node have?

Two: true and false. Items that meet the conditions go to true, the rest to false. For more than two routes, use the Switch node.

How do I combine conditions in the n8n If node?

Add several conditions and choose AND (all must match) or OR (any can match) in the dropdown between them.

Why does my If node send a number to the false branch?

The value is probably a string, for example a query parameter "10". Depending on settings, the node fails with a wrong type error or routes the item unexpectedly. Convert it first, for example with Number() in an expression.

Does the If node run once per item?

Yes. Each item is evaluated on its own, so one run can send some items to true and others to false.

What is the difference between If and Filter in n8n?

If keeps both groups and routes them to two outputs. Filter has one output and drops items that don't match.