n n8n

How to use the IF condition node on n8n

intermediate 12 min read Updated 2026-03-13
Quick Answer

The IF node in n8n splits workflow data into True and False branches based on conditions like string contains or number greater than. Configure data types, operations, and expressions referencing previous nodes; test with Execute Node. Common issues include branch execution order and type mismatches—fix by matching data types and using Merge nodes.

Prerequisites

  • n8n installed (self-hosted or cloud, version 1.0+)
  • Basic workflow with input data (e.g., HTTP Request)
  • Familiarity with expressions like {{ $json.field }}
  • Understanding of data types (string, number, boolean)

Step-by-Step Instructions

1

Access n8n Dashboard and Create Workflow

Log into your n8n instance (cloud or self-hosted). In the Workflows section, click New to create a new workflow or select an existing one. The canvas opens where you build nodes visually.
2

Add the IF Node to Canvas

Click the + button on the canvas or between connected nodes. In the node selector search bar, type IF or If. Select the If node from Core Nodes and connect it to the previous node like a trigger or HTTP Request.
Connect after a data source node outputting JSON for testing.
3

Open IF Node Configuration Panel

Double-click the IF node or click its gear icon to open the Node Settings panel. See sections for Conditions, Options, and output branches: True (top) for matching items and False (bottom) for non-matching.
4

Add a Single Condition

In Conditions, click Add Condition. Select a data type (e.g., String, Number). Choose a comparison operation (e.g., String contains). For Value 1, use a fixed value or expression like {{ $json.status }}. Set Value 2 (e.g., booked).
Use expressions to reference previous node data dynamically.
5

Configure String Comparisons

For String, use contains with {{ $json.name }} and John. Case-sensitive by default; use is for exact match. Test with Execute Node (play icon) to preview True/False outputs.
Avoid quotes for non-string exact matches.
6

Configure Number and Date Comparisons

For Number, select is greater than with {{ $json.age }} and 18; n8n auto-converts strings. For Date & Time, use is after with {{ $json.createdAt }} and ISO like 2026-03-01.
Supports relative dates for Date & Time.
7

Handle Boolean, Array, and Object Conditions

For Boolean, use is equal to with {{ $json.active }} and true. For Array, contains checks if {{ $json.tags }} includes urgent.
8

Combine Multiple Conditions with AND/OR

Click Add Condition for more rules. Select AND (all true) or OR (any true) between them. Example AND: {{ $json.age }} > 18 AND {{ $json.country }} contains US.
Single condition defaults to implicit AND.
9

Test and Debug the IF Node

Use Execute Node to preview branch outputs. Enable Always Output Data for debugging if needed, but use sparingly as it forces True branch execution.
Check data flow with green lights on both branches.
10

Connect Branches with Merge Node

After True/False branches, add a Merge node to recombine data flows. This handles sequential execution where one branch may halt others.

Common Issues & Troubleshooting

Branch not executing despite green output (e.g., TRUE halts after Wait node)

IF splits to both branches sequentially (True first); remove Wait nodes, manually execute stalled nodes, or use Merge after branches. Branches are independent.

Inverted boolean logic or falsy expression errors

Double-check expressions like <code>a.ok(nodeExists)</code>; ensure boolean evaluation matches intent (true/false).

Referencing unexecuted nodes or empty arrays

Execute previous nodes first; for arrays, use <strong>contains</strong> properly and handle empty cases with expressions.

Data type mismatches (e.g., string vs number)

Select correct data type in conditions; n8n converts where possible but match explicitly for reliability.

Case sensitivity issues in strings

Strings are case-sensitive by default; use lowercase expressions or <strong>is</strong> for exact non-case-sensitive if needed.