ComfyUI > Nodes > ComfyUI > Switch

ComfyUI Node: Switch

Class Name

ComfySwitchNode

Category
logic
Author
ComfyAnonymous (Account age: 763days)
Extension
ComfyUI
Latest Updated
2026-05-13
Github Stars
112.77K

How to Install ComfyUI

Install this extension via the ComfyUI Manager by searching for ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 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

Switch Description

Versatile logic node for conditional operations, directing data flow based on boolean evaluation for flexible workflows.

Switch:

The ComfySwitchNode is a versatile logic node designed to facilitate conditional operations within a node-based workflow. Its primary function is to act as a decision-making tool that evaluates a boolean condition and directs the flow of data based on the outcome of this evaluation. This node is particularly beneficial in scenarios where you need to dynamically choose between two different data paths or operations, depending on a specific condition. By integrating this node into your workflow, you can create more flexible and responsive systems that adapt to varying inputs and conditions, enhancing the overall efficiency and effectiveness of your projects.

Switch Input Parameters:

switch

The switch parameter is a boolean input that determines the path of execution within the node. When set to true, the node will select the on_true input for processing; when set to false, it will choose the on_false input. This parameter is crucial as it directly influences which data path is activated, allowing for dynamic decision-making within your workflow. There are no specific minimum, maximum, or default values for this parameter, as it simply requires a boolean value (true or false).

on_false

The on_false parameter is an input that is activated when the switch parameter is set to false. It represents the data or operation that should be executed if the condition is not met. This input is evaluated lazily, meaning it is only processed if the switch condition is false, optimizing performance by avoiding unnecessary computations. The specific type of data or operation that can be connected to this input is determined by the node's template, ensuring compatibility with the expected output.

on_true

The on_true parameter is an input that is activated when the switch parameter is set to true. It represents the data or operation that should be executed if the condition is met. Similar to the on_false input, this parameter is evaluated lazily, ensuring that it is only processed when necessary, thereby enhancing the efficiency of your workflow. The type of data or operation that can be connected to this input is defined by the node's template, ensuring it aligns with the expected output.

Switch Output Parameters:

output

The output parameter is the result of the node's conditional logic operation. It provides the data or result from either the on_true or on_false input, depending on the value of the switch parameter. This output is crucial as it represents the selected path of execution and is used to drive subsequent operations in your workflow. The type of data produced by this output is consistent with the node's template, ensuring seamless integration with other nodes and components in your system.

Switch Usage Tips:

  • Use the switch parameter to dynamically control the flow of your workflow, allowing for real-time decision-making based on changing conditions or inputs.
  • Ensure that both on_true and on_false inputs are properly configured with compatible data or operations to prevent execution errors and maintain the integrity of your workflow.

Switch Common Errors and Solutions:

Missing on_true or on_false Input

  • Explanation: This error occurs when the switch parameter is set to true or false, but the corresponding on_true or on_false input is not provided.
  • Solution: Ensure that both on_true and on_false inputs are connected to valid data or operations. Double-check your node connections to confirm that all necessary inputs are supplied.

Incompatible Input Types

  • Explanation: This error arises when the data or operation connected to on_true or on_false does not match the expected type defined by the node's template.
  • Solution: Verify that the inputs connected to on_true and on_false are compatible with the node's template. Adjust the data types or operations as needed to ensure compatibility.

Switch Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI
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.

Switch