
The n8n IF node checks each incoming item against one or more conditions and sends it to a true output or a false output, so the rest of your workflow can treat the two groups differently. It is the simplest way to add decisions to an n8n automation: is the order over $500, does the email subject contain “Invoice”, did the payment succeed. This guide covers how the IF node works today, every condition type, combining conditions with AND and OR, when to switch to the Switch node, and the mistakes that cause most broken workflows. For the official reference, see the n8n IF node documentation.
What Is the n8n IF Node?
The IF node is a core n8n node for conditional logic. It has one input and two outputs:
- true: items that meet your conditions.
- false: items that do not.
The important detail is that it works per item. If 20 orders arrive and 6 are over $500, those 6 go to the true branch and the other 14 go to the false branch in the same run. Both branches can continue in parallel, and a branch with no items simply does not run its next node.
How to Add and Configure an IF Node
- Add the node after the step whose data you want to check, for example a Webhook, HTTP Request or Google Sheets node.
- In Conditions, drag a field from the input panel into the first value box. n8n writes the expression for you, such as
{{ $json.total }}. - Choose the data type and operator, for example Number and “is greater than”.
- Enter the value to compare against, for example
500. - Add more conditions if needed and choose whether they combine with AND or OR.
- Run the node with test data and check which items appear on each output.
Condition Types and Operators
Each condition has a data type, and the operators available depend on it. Picking the right type is the single most important setting.
| Data type | Common operators | Example |
|---|---|---|
| String | is equal to, contains, starts with, ends with, matches regex, is empty | Subject contains “Invoice” |
| Number | is equal to, is greater than, is less than, is greater than or equal to | Total is greater than 500 |
| Date & Time | is after, is before, is equal to | Due date is before today |
| Boolean | is true, is false | Email verified is true |
| Array | contains, length equal to, is empty | Tags contains “VIP” |
| Object | is empty, is not empty, exists | Billing address exists |
Most types also offer exists and does not exist, which are useful when an API sometimes leaves a field out entirely.
Combining Conditions With AND and OR
When you add more than one condition, choose how they combine:
- AND: every condition must be true. Example: country is “UK” AND total is greater than 100.
- OR: at least one condition must be true. Example: plan is “Enterprise” OR seats is greater than 50.
A single IF node uses one combinator for all its conditions. For mixed logic such as (A AND B) OR C, either chain two IF nodes, or write the whole test as one boolean expression, for example {{ ($json.country === 'UK' && $json.total > 100) || $json.plan === 'Enterprise' }}, and check that it is true.
Useful Options: Ignore Case and Type Conversion
- Ignore Case makes string comparisons case-insensitive, so “invoice”, “Invoice” and “INVOICE” all match.
- Convert types where required (loose type validation) lets n8n compare values of different types, for example the string
"100"with the number100. With it off, a type mismatch raises an error rather than quietly returning false.
Turning on type conversion fixes many errors, but it can hide bad data. When you control the input, it is better to convert values explicitly in an Edit Fields (Set) node before the IF.
Five Practical IF Node Examples
1. Route High-Value Orders
Number condition: {{ $json.total }} is greater than 500. True sends a Slack alert to the sales team; false sends the standard confirmation email.
2. Sort Invoice Emails
After an Email Trigger (IMAP) node, String condition: subject contains “Invoice” with Ignore Case on. True passes the attachment to Extract From File and then your accounting tool; false archives the message.
3. Verify Payment Webhooks
String condition: {{ $json.status }} is equal to paid. True updates the order and responds 200 through Respond to Webhook; false notifies an admin.
4. Skip Records With Missing Data
String condition: email is not empty, AND Object condition: company exists. True continues to the CRM; false writes the record to a review sheet so nothing is lost silently.
5. Check an AI Classification
After an AI step classifies a support message, String condition: category is equal to “urgent”. True creates a high-priority ticket; false lets an AI Agent node draft a reply for review. This pattern is common in the AI workflow automations we build.
Using Expressions in IF Conditions
Any value box in a condition accepts an expression, which makes the IF node far more flexible than a fixed comparison:
- Reference earlier nodes:
{{ $('Get Customer').item.json.plan }}compares against data from a node further back in the workflow, not only the node directly before. - Compare dates:
{{ $now.minus({ days: 30 }) }}as the value lets you test whether an invoice date is older than 30 days. - Normalise text:
{{ $json.email.trim().toLowerCase() }}removes spaces and case differences before an equality check. - Count items in a list:
{{ $json.items.length }}with a Number condition checks whether an order has more than one line.
Keep expressions short. If a condition needs more than one line of logic, move it into a Code node that sets a clear boolean field, such as isEligible, and test that field in the IF node. The workflow stays readable and the logic can be tested on its own.
Testing and Debugging IF Logic
Pin sample data on the trigger node so you can re-run the workflow with the same input while you adjust conditions. After each run, open the IF node and compare the item counts on the true and false outputs with what you expected. If an item is on the wrong side, check its exact value and type in the input panel; the cause is usually visible there.
IF Node vs Switch Node
The IF node has exactly two outputs. When you need three or more routes, use the Switch node instead of chaining IF nodes.
| Feature | IF node | Switch node |
|---|---|---|
| Outputs | Two (true and false) | As many as you define |
| Best for | Yes or no decisions | Routing by category, region or status |
| Modes | Conditions | Rules, or an expression that returns the output number |
| Multiple matches | Not applicable | Optional: send an item to every matching output |
| Readability with many cases | Poor when chained | Good |
Use the Filter node when you only want to keep matching items and drop the rest, with no false branch at all.
Common Mistakes and How to Fix Them
- Comparing the wrong types. “100” as a string is not 100 as a number. Set the correct data type or convert the value first.
- Expecting one result for the whole run. The node evaluates every item separately. If you need one decision for the batch, aggregate first with the Aggregate or Summarize node.
- Forgetting the empty branch. If no items take a branch, its nodes do not run. If later steps must always run, bring the branches back together with a Merge node, or turn on Always Output Data where appropriate.
- Whitespace and case. “Paid ” with a trailing space fails an equality check. Trim values or use Ignore Case.
- Missing fields. An undefined field can cause errors with strict type checks. Test with exists first, or provide a default in the expression, for example
{{ $json.total ?? 0 }}. - Too many chained IF nodes. Three or more in a row is a sign you need a Switch node.
When n8n Is the Right Tool
Conditional logic like this is where n8n shines compared with simpler tools, especially when combined with code nodes and AI. If you are still choosing a platform, read our comparison of n8n vs Make vs Zapier.
FAQ
What does the IF node do in n8n?
It checks each incoming item against one or more conditions and routes it to a true or a false output. Items on each output then continue through different steps of the workflow.
How do I add multiple conditions to an n8n IF node?
Click Add condition, then choose whether the conditions combine with AND (all must be true) or OR (any must be true). For mixed logic, chain IF nodes or write a single boolean expression.
What is the difference between the IF and Switch nodes in n8n?
The IF node has two outputs, true and false. The Switch node can have many outputs and routes each item by rules or by an expression, which makes it better for three or more paths.
Why does my n8n IF node always return false?
The most common causes are a data type mismatch (a number stored as text), extra whitespace, different letter case or a field path that does not exist. Check the input data, set the correct type and try Ignore Case or explicit conversion.
Can the IF node check AI output?
Yes. Ask the AI step to return a fixed label or structured JSON, then test that field with the IF node. Free text from a model is unreliable to compare, so constrain the output format first.