node cookbook

n8n IF Node: Branching Patterns, Common Mistakes, and Expression Errors

Use the IF node when a workflow needs to branch based on conditions, such as status, field values, dates, numbers, or whether data exists.

Independent third-party notes. n8n is a trademark of its owner and is referenced only for compatibility and troubleshooting context.

Quick Answer

Use the IF node when a workflow needs to branch based on conditions, such as status, field values, dates, numbers, or whether data exists.

Problem Pattern

The user knows they need branching, but the real risk is data shape, type comparison, and downstream nodes referencing the wrong branch.

Key Facts

Node role
Route items down true or false branches based on conditions.
Best fit
Simple workflow branching and validation checks.
Common inputs
Fields, expressions, booleans, dates, numbers, strings, and existence checks.
Common companion nodes
Merge, Set, Code, Webhook, Schedule Trigger, and app nodes.

Recommended Steps

  1. Place the IF node after the node that creates or retrieves the value to test.
  2. Choose the condition type that matches the data shape.
  3. Map or write the left-side value using a field or expression.
  4. Set the comparison value or existence rule.
  5. Test both true and false branches with representative data.

Verification

  • Known true examples go to the true branch.
  • Known false examples go to the false branch.
  • Downstream nodes do not reference data that is unavailable on the chosen branch.

Warnings

  • A branch can fail later if it references data from a node that did not execute on that path.
  • String, number, boolean, and date comparisons can behave differently if incoming data is not normalized.

Common Mistakes

  • Comparing a number stored as text without normalizing it.
  • Expecting both branches to run for each item.
  • Referencing a node from the other branch later in the workflow.
  • Using a complex IF condition where a Code node would be clearer.

Examples

Lead routing condition A common workflow branching pattern.
If lead.score >= 80:
  true branch -> notify sales in Slack
  false branch -> append to nurture sheet

FAQ

Should I use IF or Switch?

Use IF for a two-way true/false split. Use Switch-style routing when you need several named branches.

Why does a downstream expression fail after IF?

That branch may not have executed the node being referenced, or the item shape differs between branches.

Sources