ComfyUI > Nodes > Basic data handling > if/elif/.../else

ComfyUI Node: if/elif/.../else

Class Name

Basic data handling: IfElifElse

Category
Basic/flow control
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

if/elif/.../else Description

The `IfElifElse` node enables conditional branching for dynamic decision-making in workflows.

if/elif/.../else:

The IfElifElse node is a powerful tool designed to implement conditional branching within a workflow, allowing for dynamic decision-making based on multiple conditions. This node evaluates a primary condition and, if it is true, returns a specified value. If the primary condition is false, it proceeds to evaluate a series of elif (else if) conditions in sequence. If any elif condition is true, the corresponding value is returned. If none of the conditions are true, the node defaults to returning the value associated with the else condition. This functionality is particularly useful in workflows where multiple potential outcomes need to be managed based on varying conditions, providing a flexible and efficient way to control data flow and logic execution.

if/elif/.../else Input Parameters:

if

The if parameter is a boolean input that serves as the primary condition for the node. If this condition evaluates to true, the node will return the value associated with the then parameter. This parameter is crucial as it determines the initial path of execution within the node. There are no minimum or maximum values as it is a boolean, but it defaults to requiring a true or false input.

then

The then parameter is the value returned when the if condition is true. It can be of any data type, allowing for flexibility in what is returned. This parameter is marked as lazy, meaning it is only evaluated if the if condition is true, optimizing performance by avoiding unnecessary computations.

elif_0, elif_1, ...

These parameters represent additional boolean conditions that are evaluated sequentially if the if condition is false. Each elif condition has a corresponding then_0, then_1, etc., which are the values returned if the respective elif condition is true. These parameters allow for multiple conditional checks within a single node, providing a structured way to handle complex decision-making processes.

then_0, then_1, ...

These parameters are the values returned when their corresponding elif conditions are true. Like the then parameter, they can be of any data type and are evaluated lazily, meaning they are only computed if their respective elif condition is true. This ensures that only necessary computations are performed, enhancing the node's efficiency.

else

The else parameter is the fallback value returned when none of the if or elif conditions are true. It acts as a default output, ensuring that the node always produces a result even if all conditions fail. This parameter is also evaluated lazily, meaning it is only computed if all other conditions are false.

if/elif/.../else Output Parameters:

result

The result parameter is the output of the node, representing the value returned based on the evaluation of the if, elif, and else conditions. It can be of any data type, depending on the values provided to the then, then_0, then_1, ..., and else parameters. This output is crucial as it determines the flow of data and logic in the workflow, allowing for dynamic and conditional execution paths.

if/elif/.../else Usage Tips:

  • Use the IfElifElse node to simplify complex decision-making processes by consolidating multiple conditional checks into a single node, reducing the need for multiple separate IfElse nodes.
  • Ensure that the elif conditions are ordered from most to least likely to be true to optimize performance, as the node evaluates conditions sequentially and stops once a true condition is found.

if/elif/.../else Common Errors and Solutions:

Missing then or else value

  • Explanation: If the if condition is true and the then value is not provided, or if all conditions are false and the else value is not provided, the node may not function as expected.
  • Solution: Ensure that all necessary values for then, elif, and else are provided to avoid unexpected behavior.

Incorrect boolean input

  • Explanation: The if and elif parameters require boolean inputs. Providing non-boolean values can lead to errors in condition evaluation.
  • Solution: Verify that all if and elif conditions are supplied with valid boolean values (true or false) to ensure proper execution.

if/elif/.../else Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

if/elif/.../else