Skip to main content

Filter List

Uncontrolled node

Overview

The Filter List node iterates through an input list and returns a new list containing only the elements that match a specified condition. The filtering logic is defined using a Python expression that is evaluated for each element in the list.

By default, if no pattern is provided, the node filters out falsy values (such as null, undefined, false, 0, or empty strings).

Pattern Variables

When writing the filter pattern, you have access to the following automatically defined variables:

  • value — The current element being evaluated from the list
  • index — The zero-based index of the current element
  • list — The entire input list (useful for checking against other elements)

Additionally, any other inputs connected to the node are available as variables with the same name as the input socket.

Dynamic Inputs

The node automatically detects variable names referenced in your pattern (excluding the reserved names above) and creates corresponding input sockets. For example, if your pattern references a variable called threshold, a threshold input will appear on the node.

Inputs

InputTypeDescriptionDefault
ListDataThe list to filter.
PatternCodeA Python expression that evaluates to a boolean. If true, the element is kept.Empty string (filters falsy values)
[Dynamic]DataAny variables referenced in the pattern (except value, index, list) become inputs.

Outputs

OutputTypeDescription
OutputDataThe filtered list containing only elements that passed the pattern check.

Runtime Behavior and Defaults

  • Uncontrolled Node: This node runs automatically when its inputs change; it does not require an event trigger.
  • Python Execution: The pattern is executed using the Python runtime. Each element is evaluated sequentially.
  • Timeout: Pattern execution is limited to the platform's maximum code execution time (typically 30 seconds). If exceeded, a RunCodeError is thrown.
  • Default Filtering: If the pattern is empty or not provided, the node filters out falsy values using JavaScript truthiness (equivalent to list.filter(v => v)).
  • Error Handling: If the Python code throws an error or returns an error object, the node will throw a RunCodeError and stop execution.

Example

To filter a list of numbers to include only values greater than 10:

  1. Connect your list of numbers to the List input.
  2. Set the Pattern to:
    value > 10
  3. The Output will contain only numbers greater than 10.

To filter a list of objects based on a dynamic threshold:

  1. Connect your list to the List input.
  2. Add a Number node and connect it to the dynamically created threshold input (after typing threshold in the pattern).
  3. Set the Pattern to:
    value["score"] > threshold
  4. The Output will contain only objects where the score property exceeds the threshold value.

To get every second element (even indices):

index % 2 == 0