ComfyUI Node: if/else

Class Name

Basic data handling: IfElse

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/else Description

The IfElse node enables conditional branching in ComfyUI, directing data flow based on conditions.

if/else:

The IfElse node is a fundamental component in the ComfyUI workflow that facilitates conditional branching, allowing you to direct the flow of data based on a specified condition. This node evaluates a boolean condition and returns one of two possible values depending on whether the condition is true or false. By incorporating this node into your workflow, you can create dynamic and responsive processes that adapt to varying inputs and conditions, enhancing the flexibility and efficiency of your data handling tasks. The IfElse node is particularly useful for scenarios where decisions need to be made based on specific criteria, enabling you to streamline operations and automate decision-making processes within your AI art projects.

if/else Input Parameters:

condition

The condition parameter is a boolean input that determines which value will be returned by the node. If the condition evaluates to true, the node will return the value specified in the if_true parameter; otherwise, it will return the value specified in the if_false parameter. This parameter is crucial as it dictates the flow of data within the workflow, allowing for conditional logic to be implemented. There are no minimum or maximum values for this parameter as it is strictly a boolean (true or false).

if_true

The if_true parameter represents the value that will be returned if the condition evaluates to true. This parameter can accept any data type, making it versatile for various applications. It is marked as "lazy," meaning it is only evaluated if the condition is true, which can optimize performance by avoiding unnecessary computations. There are no specific constraints on the type of data this parameter can hold, allowing for flexibility in its use.

if_false

The if_false parameter is the counterpart to if_true and represents the value that will be returned if the condition evaluates to false. Like if_true, this parameter can accept any data type and is also marked as "lazy," ensuring it is only evaluated when necessary. This feature helps in optimizing the workflow by preventing the evaluation of data that is not needed, thus saving computational resources.

if/else Output Parameters:

result

The result parameter is the output of the IfElse node, which will be either the value from if_true or if_false depending on the evaluation of the condition. This output is crucial as it determines the subsequent flow of data in the workflow. The flexibility of the result parameter to hold any data type allows it to seamlessly integrate with other nodes and processes within the ComfyUI environment, making it a vital component for conditional logic implementation.

if/else Usage Tips:

  • Use the IfElse node to simplify complex workflows by breaking them down into conditional branches, which can make your processes more manageable and easier to understand.
  • Take advantage of the "lazy" evaluation feature to optimize performance, especially in workflows with heavy computations or large datasets, by ensuring that only necessary data is processed.
  • Consider using the IfElse node in conjunction with other control flow nodes to create more sophisticated decision-making structures within your AI art projects.

if/else Common Errors and Solutions:

Missing if_true or if_false value

  • Explanation: This error occurs when the condition is true or false, but the corresponding if_true or if_false value is not provided.
  • Solution: Ensure that both if_true and if_false parameters are set with appropriate values to avoid this error.

Invalid condition type

  • Explanation: The condition parameter must be a boolean value. If a non-boolean value is provided, the node will not function correctly.
  • Solution: Verify that the condition parameter is set to either true or false to ensure proper operation of the node.

if/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/else