Switch Node

This tutorial workflow demonstrates how to use ComfyUI's ComfySwitchNode to route between two inputs with a simple boolean toggle. It includes two focused examples: Example 1 - String Selection shows how to switch between two prompt strings using PrimitiveString and PrimitiveStringMultiline, previewing the active choice with PreviewAny. Example 2 - LoRA Switch shows how to toggle a LoRA on and off around a base model: UNETLoader loads Z-Image-Turbo, LoraLoaderModelOnly applies a selected LoRA, and a ComfySwitchNode chooses either the plain UNet (on_false) or the LoRA-modified UNet (on_true) to feed the generation node.

Under the hood, ComfySwitchNode exposes four pins: on_false, on_true, switch (boolean), and output. When the switch is OFF (false), the output forwards whatever is connected to on_false; when ON (true), it forwards on_true. The workflow wires these switches to real tasks. The text switch selects a single prompt string used downstream, and the LoRA switch controls whether a LoRA weight is applied to the Z-Image-Turbo UNet before image generation. A SaveImage node captures results for easy A/B comparison, and MarkdownNote blocks explain the routing inline. The generation path uses Z-Image-Turbo via UNETLoader and a generation node (ID 0f79b7f9-d214-4587-b475-bc429519b976) that consumes the chosen model and prompt to render images.

API

Use this workflow from code

Every Comfy workflow is a JSON graph. The payload below is this workflow, exactly as ComfyUI runs it — fetch it from the URL, keep it in version control, or load it in ComfyUI and run it node by node.

GET https://comfy.org/workflows/download/2b3403ae14e9.json
Fetching workflow JSON…

Run it from Python or TypeScript with the Comfy SDK. The same code targets Comfy Cloud or a ComfyUI you host yourself — only the base URL changes.

# Install (beta)
pip install comfy-sdk        # Python
npm i @comfyorg/sdk          # TypeScript

# Run "Switch Node" (Python)
from comfy_sdk import Comfy

client = Comfy(api_key="comfyui-...")

# This workflow, exported in API format (see note below)
wf = client.workflows.from_file("basic_switch_node_api.json")

job = client.run(wf)
for output in job.get_outputs("63"):  # SaveImage
    output.to_file(output.name)

The SDK takes a workflow in API format: open this workflow in ComfyUI and use File → Export Workflow (API). API access requires a Comfy Cloud plan with an API key. SDK docs · Get an API key

FAQ

Frequently Asked Questions

View all workflows
Character
Cinematic
Image to Video
Lip Sync
Multiple Angles
Portrait
Style Reference
Style Transfer
Text to Video
Video Generation
Video
Showing 30 of 30 templates