Switch (Drawer)
A/B switch with lazy evaluation — the losing branch never runs
- A
- B
- output
There are two shapes of "switch" in ComfyUI, and people mix them up constantly. An A/B switch has a selector and passes whichever branch you point at. A fallback switch has no selector - it walks its inputs and passes the first one that isn't empty. DrawerSwitch is the first kind, with one twist that makes it genuinely better than most: the branch you don't pick is never executed.
That's not marketing. DrawerSwitch is written against ComfyUI's newer V3 API (comfy_api.latest) and declares its inputs lazy. When the graph runs, the node's check_lazy_status decides what it actually needs: if B has a value, it never asks for A at all. So you can hang a whole expensive branch - a second sampler, an img2img chain, a heavy upscaler - off A, and when B wins, none of it runs. Most ComfyUI switches still execute both branches and let the downstream cache sort it out; this one doesn't.
Behavior and inputs
- A - optional, any type.
- B - optional, any type.
- output - returns B if it's connected and non-empty (a string B is "empty" if it's blank after stripping), otherwise A.
So B wins whenever it has content. If you're thinking "which slot do I wire my preferred branch into?" - the answer is B. If you only want A to ever win, don't connect B.
The three ports share one type via MatchType.Template: connect an IMAGE into A and both B and output become IMAGE sockets; disconnect everything and it reverts to "any". That's the type-locking behavior, and it means you can't accidentally mix a model on one side and a latent on the other without a visible error.
It also belongs to ComfyUI-Drawer, Kuroi's drawer platform, so in the Deck it gets a clean A/B toggle - a switch you can flip from a tablet.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/Kuroi961/ComfyUI-Drawer.git
pip install -r ComfyUI-Drawer/requirements.txt
Or search ComfyUI-Drawer in ComfyUI Manager. requirements.txt is a single line (Send2Trash), no models. Because it's a V3-API node, keep ComfyUI reasonably recent - very old installs predate the comfy_api authoring API and won't load it.
Gotchas
- It validates that at least one of A or B is connected - and the error message is in Japanese ("please connect at least one of A and B"). Don't panic; it just means you left both ports empty.
- B wins on non-empty, not on "connected". A connected-but-blank string B falls through to A.
- If you want first non-empty wins across many inputs, that's DrawerSwitchChain (last-connected-non-empty) or rgthree's Any Switch - different tools for different shapes. This node is deliberately a two-way valve.
For a workflow where you keep two loaders or two pipelines alive and flip between them, DrawerSwitch is the one I'd use - the lazy execution means "keep both branches in the graph" costs you nothing when the switch is set.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| Aopt | COMFY_MATCHTYPE_V3 | — | |
| Bopt | COMFY_MATCHTYPE_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | COMFY_MATCHTYPE_V3 | — |