Skip to content

If#

Use the If node to split a workflow conditionally based on comparison operations.

Examples and templates

For usage examples and templates to help you get started, refer to n8n's IF integrations list.

Add conditions#

Add comparison conditions using the Add Condition filter. The available comparison operations vary for each data type.

String:

  • exists
  • doesn't exist
  • is equal to
  • isn't equal to
  • contains
  • doesn't contain
  • starts with
  • doesn't start with
  • ends with
  • doesn't end with
  • matches regex
  • doesn't match regex

Number:

  • exists
  • doesn't exist
  • is equal to
  • isn't equal to
  • is greater than
  • is less than
  • is greater than or equal
  • is less than or equal

Date & Time:

  • exists
  • doesn't exist
  • is equal to
  • isn't equal to
  • is after
  • is before
  • is after or equal
  • is before or equal

Boolean:

  • exists
  • doesn't exist
  • is true
  • is false
  • is equal to
  • isn't equal to

Array:

  • exists
  • doesn't exist
  • is equal to
  • isn't equal to
  • contains
  • doesn't contain
  • length equal to
  • length not equal to
  • length greater than
  • length less than
  • length greater than or equal
  • length less than or equal

Object:

  • exists
  • doesn't exist
  • is empty
  • isn't empty

AND / OR#

If you have more than one condition, you can choose either:

  • AND: data must match all conditions to be true.
  • OR: data only needs to match one of the conditions to be true.

Branch execution with If and Merge nodes#

0.236.0 and below

n8n removed this execution behavior in version 1.0. This section applies to workflows using the v0 (legacy) workflow execution order. By default, this is all workflows built before version 1.0. You can change the execution order in your workflow settings.

If you add a Merge node to a workflow containing an If node, it can result in both output branches of the If node executing.

The Merge node is triggered by one branch, then goes and executes the other branch.

For example, in the screenshot below there's a workflow containing a Edit Fields node, If node, and Merge node. The standard If node behavior is to execute one branch (in the screenshot, this is the true output). However, due to the Merge node, both branches execute, despite the If node not sending any data down the false branch.

Screenshot of a workflow. The workflow has an Edit Fields node, followed by an If node. It ends with a Merge node.

View example workflows and related content on n8n's website.

Refer to Splitting with conditionals for more information on using conditionals to create complex logic in n8n.

If you need more than two conditional outputs, use the Switch node.