Master the n8n If Node: 11 Practical Examples for Conditional Workflows
Struggling to automate complex decisions in your workflows? The n8n If Node lets you route data based on conditions - but only if you know how to use it properly. This comprehensive guide walks through 11 real-world examples covering strings, numbers, arrays, objects and more, transforming your workflows from linear to intelligent.
What Is the n8n If Node?
The n8n If Node implements conditional logic - the "if this, then that" principle that powers intelligent automation. Like programming if-else statements, it evaluates conditions and routes workflow items down different paths based on whether those conditions are met.
Before diving into examples, it's crucial to understand that the If Node works with six core data types: numbers (integers/floats), strings (text), booleans (true/false), dates, arrays (lists), and objects (key-value pairs). Each type has specific comparison operators available.
Pro Tip: For complex branching beyond basic if-else, n8n offers the Switch Node and Code Node. The If Node is perfect for simple binary decisions, while these alternatives handle more sophisticated logic.
Number Comparisons (5 Examples)
Numbers are among the most common data types used in conditional logic. The If Node provides several operators for numeric comparisons:
1. Greater Than or Equal To
This operator checks if a number is either larger than or exactly equal to your comparison value. For example, checking if a lead's potential deal size is at least $10,000:
amount ≥ 10000 → True amount < 10000 → False 2. Greater Than
Similar but excludes the equal case. Useful for thresholds where the exact value should be excluded:
score > 90 → A grade score ≤ 90 → Not A grade 3. Less Than or Equal To
The inverse of greater than or equal to. Common for age verification or expiration dates:
age ≤ 21 → Under drinking age age > 21 → Of drinking age 4. Less Than
Exclusive version of less than or equal to. Use when the boundary value should be excluded:
temperature < 32 → Freezing temperature ≥ 32 → Not freezing 5. Equal To / Not Equal To
Exact matches or mismatches. Essential for status codes or specific numeric values:
statusCode == 200 → Success statusCode != 200 → Error Implementation Tip: Always drag your field into the condition box rather than typing manually - this ensures proper JSON path syntax and prevents errors.
String Comparisons (4 Examples)
Text processing requires different operators than numbers. The If Node offers powerful string-specific conditions:
1. Exact Match (Case Sensitive)
Standard equality check where capitalization matters. Useful for codes, usernames, or other case-sensitive identifiers:
"Admin" == "Admin" → True "admin" == "Admin" → False 2. Contains / Does Not Contain
Checks if a substring exists within your text. Perfect for filtering content or categorizing messages:
"Order #123" contains "Order" → True "Payment failed" contains "success" → False 3. Starts With / Ends With
Verifies text position. Essential for file extensions, URL routing, or ID prefixes:
"report.pdf" ends with ".pdf" → True "https://..." starts with "http" → True 4. Regular Expression Matching
Advanced pattern matching for complex validations (emails, phone numbers, etc.):
email matches /^[^@]+@[^@]+\.[^@]+$/ → Valid format phone matches /^\d{3}-\d{3}-\d{4}$/ → US format Watch Out: Whitespace matters in string comparisons! Trailing spaces can cause "equal" strings to evaluate as different. Use the trim() function if needed.
Boolean Logic (True/False Conditions)
Boolean values represent simple true/false states. The If Node provides straightforward operators:
1. Is True / Is False
Direct evaluation of boolean fields. Ideal for flags and binary statuses:
isActive is True → Process user isApproved is False → Route for review 2. Exists / Is Empty
Checks if a boolean field has a value at all. Helpful for error handling:
hasSubscription exists → True isVerified is empty → False (if field exists) At 8:45 in the video, the tutorial demonstrates how boolean conditions can control workflow paths for approval processes, with true routing to one branch and false to another.
Date and Time Comparisons
Date comparisons require special handling due to timestamps. Key operators include:
1. Is Before / Is After
Compares dates chronologically. Essential for deadlines, expiration, and scheduling:
dueDate is before today → Late startDate is after now → Future event 2. Is Equal To (With Caution)
Dates with timestamps rarely match exactly. For day-only comparisons, first format dates:
formatDate(createdAt, "YYYY-MM-DD") == "2025-09-29" → True if created today Pro Solution: Use expressions to strip time components before date equality checks. The video at 15:30 shows exactly how to implement this.
Working With Arrays
Arrays (lists) require specialized operators to check contents and properties:
1. Contains Value
Checks if an item exists in the array. Case sensitivity applies to strings:
["apple","banana"] contains "apple" → True [1,2,3] contains 5 → False 2. Length Comparisons
Evaluates the number of items in an array. Useful for validation:
tags.length > 0 → Has tags selectedItems.length == 3 → Exactly 3 items The tutorial at 18:15 demonstrates filtering an array of products based on multiple conditions, showing practical e-commerce applications.
Working With Objects
Objects (key-value pairs) require accessing nested properties for conditions:
1. Property Existence
Checks if a specific field exists in the object:
user.email exists → True order.discountCode exists → False 2. Nested Property Evaluation
Drills into object properties for conditional checks:
customer.address.country == "US" → True product.inventory.count > 0 → In stock At 22:40 in the video, you'll see how to evaluate multiple properties of a customer object to determine eligibility for different marketing flows.
Multiple Conditions (AND/OR)
Real-world decisions often require evaluating multiple factors simultaneously:
1. AND Conditions
All conditions must be true. Example: High-value leads in your target industry:
dealSize > 10000 AND industry == "Technology" → True dealSize > 10000 AND industry == "Retail" → False 2. OR Conditions
Any condition being true suffices. Example: Contact methods for outreach:
hasEmail == true OR hasPhone == true → Contactable hasEmail == false AND hasPhone == false → Unreachable Limitation: n8n's If Node doesn't support mixing AND/OR in the same condition. For complex logic, consider multiple If Nodes or a Switch/Code Node.
Nested If Logic
For sequential decision-making, you can chain If Nodes:
Implementation Example
- First If Node: Is customer active?
- Second If Node (on true branch): Has made purchase in last 30 days?
- Third If Node: Is customer in premium tier?
This creates a decision tree where each condition refines the audience further. The video at 26:50 walks through building a nested qualification workflow for lead scoring.
Type Conversion Considerations
When comparing different data types, n8n can attempt automatic conversion:
Automatic Conversion
With "Convert types when required" enabled, n8n will try to cast values:
"42" (string) → 42 (number) for comparison 1 (number) → true (boolean) "false" (string) → false (boolean) Best Practice: Explicitly convert data types before comparison for predictable results. Use Change Node or expressions to standardize types early in your workflow.
Watch the Full Tutorial
For visual learners, the full 32-minute tutorial walks through each example with real-time workflow building. Pay special attention at 14:20 where we demonstrate handling date comparisons - a common pain point for many users.
Key Takeaways
The n8n If Node transforms static workflows into dynamic, intelligent automations by routing data based on conditions. Mastering its various comparison operators across different data types unlocks powerful automation possibilities.
In summary: 1) Use appropriate operators for each data type 2) Handle edge cases (whitespace, timestamps) 3) Pre-convert data types when possible 4) For complex logic, consider Switch or Code Nodes 5) Test conditions thoroughly with varied data samples.
Frequently Asked Questions
Common questions about this topic
The n8n If Node allows you to add conditional logic to your workflows, similar to if-else statements in programming. It routes items to different branches based on whether specified conditions are met.
You can use it with strings, numbers, arrays, objects, booleans, and dates to create dynamic workflows that respond differently based on your data. This enables complex decision-making within your automations without manual intervention.
- Routes workflow items based on conditions
- Works with all major data types
- Essential for intelligent automation
The n8n If Node can evaluate six main data types: strings (text), numbers (integers and floats), booleans (true/false), dates (with timestamps), arrays (lists of values), and objects (key-value pairs).
Each data type has specific comparison operators available, like equals, contains, greater than, or exists for different data structures. The Node automatically adjusts available operators based on the data type you're working with.
- Strings: equals, contains, starts/ends with
- Numbers: greater/less than, equals
- Booleans: is true/false
By default, string comparisons in n8n are case-sensitive. However, you can enable the 'Ignore Case' option when setting up your If Node condition.
This makes comparisons case-insensitive, so 'Example' would match 'example' or 'EXAMPLE'. This is particularly useful when processing user input or data from different sources that might have inconsistent capitalization.
- Default is case-sensitive matching
- 'Ignore Case' option available
- Critical for user-generated content
AND conditions require all specified conditions to be true for the item to route to the true branch. OR conditions only require any one condition to be true.
For example, with AND, 'genre is metal AND not seen live' both must be true. With OR, 'genre is metal OR genre is bluegrass' would pass if either condition is met. AND narrows results while OR expands them.
- AND: All conditions must be true
- OR: Any condition can be true
- Cannot mix AND/OR in same If Node
Date comparisons in n8n can evaluate if a date is before, after, or equal to another date, including timestamp comparisons. For precise day-only comparisons, you may need to format the date first using expressions.
The If Node offers operators like 'is after', 'is before', and 'is equal to' specifically for date/time data types. Remember that 'is equal to' compares full timestamps, so identical calendar dates with different times won't match.
- Use 'is before/after' for chronological checks
- Format dates for day-only comparisons
- Timestamps affect equality checks
Nested If Nodes (multiple If Nodes in sequence) are useful when you need to make sequential decisions. For example, first checking if a lead is qualified (condition 1), then if they're in your target industry (condition 2), then if they've engaged recently (condition 3).
However, for complex logic with many conditions, consider using the Switch Node or Code Node instead for better readability. Nested Ifs can become difficult to maintain beyond 2-3 levels deep.
- Good for sequential qualification
- Limit to 2-3 levels when possible
- Consider Switch Node for complex logic
Common mistakes include: not accounting for whitespace in string comparisons, forgetting about case sensitivity, comparing dates without considering timestamps, not converting data types before comparison, and creating overly complex nested If structures.
Always test your conditions with varied sample data to catch edge cases. The most robust workflows handle unexpected data formats gracefully by standardizing inputs early in the workflow.
- Whitespace and case sensitivity issues
- Timestamp mismatches in date comparisons
- Overly complex nested conditions
GrowwStacks helps businesses implement conditional logic in their n8n workflows to automate complex decision-making. We can design custom workflows that route data appropriately based on your business rules.
Our team will integrate these automations with your existing systems and handle all edge cases, ensuring your workflows process data correctly in every scenario. We'll save you hours of manual processing by automating these decisions.
- Custom conditional workflow design
- Integration with your existing tools
- Free 30-minute consultation to discuss your needs
Ready to Automate Your Business Decisions?
Conditional logic separates basic workflows from intelligent automations. Let GrowwStacks build custom n8n workflows that make smart decisions for your business - implemented in days, not months.