C Switch Boolean Latent
The txt2img / img2img switch that doesn't run the dead branch
- on_true
- on_false
- latent
C Switch Boolean Latent is the switch node that makes "txt2img or img2img?" a checkbox instead of a surgery. It takes two LATENT inputs - typically an empty latent on one side and a VAE-encoded image on the other - and a boolean picks which one reaches your sampler. It's the exact A/B pattern as the pack's conditioning and float switches, applied to the thing that determines whether you're generating from noise or from a starting image.
If you've ever kept two copies of a workflow because switching between pure generation and image-to-image meant rewiring half the graph, this is the node that collapses that into one toggle. Combine it with the pack's I2iToggle boolean and a denoise switch: I2iToggle on → latent comes from the encoded image, denoise drops below 1.0, and you're doing img2img. Off → empty latent, denoise 1.0, pure txt2img. One checkbox drives all of it.
The inputs that matter
- on_true -
LATENT, used when the boolean is on. - on_false -
LATENT, used when it's off. - boolean - the selector, default on.
- Output latent - whichever input won, wired into a sampler.
Both latent inputs are lazy, and this is where laziness shines: the losing branch's whole chain doesn't execute. If on_false feeds off a VAE Encode of a big reference image, leaving the switch on means that encode never runs - you don't pay for the img2img path you didn't take, and you don't hold its tensors in VRAM. That's not a micro-optimization on a tight card; it's the difference between a workflow that fits and one that OOMs.
Why you'd reach for it
Beyond the obvious txt2img/img2img toggle, it's the building block for any "two paths, one sampler" graph: an inpaint branch vs a fresh render, a reference-latent pass vs an empty one, an experiment you want to flip mid-run without touching wires. Because it's a plain latent type, anything that emits a latent (Empty Latent, VAE Encode, a refiner's latent) can sit on either side.
Install
Part of duckcomfy personal nodes. ComfyUI Manager → search "duckcomfy personal nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/duckcomfy/duckcomfy_personal_nodes
Restart ComfyUI. No pip dependencies, no model downloads.
Gotchas
The same lazy-input rule applies: if the unselected side is unwired and you later flip the boolean onto it, the run errors because that input no longer exists. And remember a latent is only as good as what made it - an empty latent and a VAE-encoded image must match in resolution (both from the same width/height, or the sampler will reject the mismatch), so keep your empty-latent dimensions in step with your reference image. Finally, the switch picks the latent; it doesn't adjust denoise. If you're going img2img, wire the denoise change separately - the latent alone won't lower it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| on_true | LATENT | — | |
| on_false | LATENT | — | |
| boolean | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |