Any icon

Any

Checks if any element matches and returns the matches. Only if none matches, the "None"-Branch is filled

Overview

The Any node is a conditional routing node for n8n workflows. It evaluates one or more user-defined conditions (on booleans, numbers, strings, or dates) against each incoming item and routes items based on whether they match the specified criteria. The node can be used to filter, branch, or segment data flows according to complex logic, such as:

  • Filtering records where a field matches a value or pattern.
  • Routing items that meet any or all of several conditions.
  • Segmenting data by date, number, string, or boolean comparisons.

Practical examples:

  • Route all orders with an amount greater than $1000 to a special processing branch.
  • Filter contacts whose email addresses end with "@example.com".
  • Separate items created after a certain date.

Properties

Name Type Meaning
Conditions fixedCollection A set of rules to compare values. Each rule can be of type Boolean, Date & Time, Number, or String, with specific comparison operations. Multiple conditions can be defined and combined.
Combine options Determines if ALL or ANY of the conditions must be met for an item to be considered a match. ("ALL" = all conditions must be true; "ANY" = at least one condition must be true.)
Return options Specifies what to return in case of matches: "ALL" (all input items), "MATCHES" (only matching items), or "FIRST" (only the first matching item).

Condition Types

  • Boolean: Compare two boolean values using "Equal" or "Not Equal".
  • Date & Time: Compare two dates/times using "Occurred After" or "Occurred Before".
  • Number: Compare two numbers using operations like "Smaller", "Larger", "Equal", "Is Empty", etc.
  • String: Compare two strings using operations like "Contains", "Starts With", "Regex Match", "Is Empty", etc.

Output

The node has three outputs:

  1. any: Items that matched the conditions (according to the "Combine" and "Return" settings).
  2. none: Items that did not match the conditions.
  3. statistics: An object with statistics about the operation.

Output Structure

  • any (first output):
    • Depending on the "Return" property:
      • ALL: All input items.
      • MATCHES: Only items that matched the conditions.
      • FIRST: Only the first item that matched.
  • none (second output):
    • Items that did not match the conditions.
  • statistics (third output):
    • An object with the following fields:
      {
        "any": false,   // true if no items matched
        "none": false,  // true if some items matched
        "kept": 0,      // number of items kept (matched)
        "dropped": 0    // number of items dropped (not matched)
      }
      

Dependencies

  • moment: Used for date/time parsing and comparison.
  • n8n-workflow: For error handling and workflow integration.

No external API keys or environment variables are required.

Troubleshooting

Common issues:

  • Invalid DateTime values: If a date/time value cannot be parsed, the node will throw an error:
    The value "<value>" is not a valid DateTime.
    Resolution: Ensure your date/time inputs are in a valid format (e.g., ISO 8601).

  • Incorrect condition configuration: If you use incompatible types or leave required fields empty, the node may not behave as expected.
    Resolution: Double-check that all conditions are properly configured and that the correct types are used.

  • Regex errors: If a regex pattern is invalid, it may cause unexpected results.
    Resolution: Test your regex patterns before using them in the node.

Links and References

Discussion