Nodes/Crystools/πŸͺ› Switch latent
ComfyUI Node Runs on cloud

πŸͺ› Switch latent

Flip between two LATENT paths with one boolean

By crystianΒ·Created 3 years agoΒ·Updated 10 months agoΒ· 1,946
πŸͺ› Switch latent
  • on_true
  • on_false
  • latent
β—„booleantrueβ–Ί

This one does exactly what it says and nothing more, which is the appeal: you've got two LATENT sources feeding the same downstream (a VAE Decode, a second-pass sampler, whatever), and you want to flick between them without rewiring the graph every time. Switch latent is a boolean toggle that picks one and passes it through.

It's the LATENT-typed member of a small family Crystools ships - there's a matching Switch mask, and presumably string/image/conditioning variants documented in the README's Switch section, all built on the same idea. The reason a typed switch exists at all alongside the generic Switch from any node (also in this pack) is that ComfyUI's type system checks connections at graph-build time; a LATENT-specific switch guarantees the socket only ever accepts latents, which catches a wrong connection immediately instead of failing at execution.

How it works

There's no logic to speak of. It holds two LATENT inputs and a boolean, and outputs whichever input the boolean currently points to.

The inputs and outputs that matter

  • on_true / on_false - both required LATENT inputs. Wire your two candidate latents here - say, the output of a base KSampler into one and a hires-fix pass into the other.
  • boolean - defaults to true, so out of the box it's passing on_true through. Flip it and the output switches to on_false instead.
  • Output: latent - whichever one won, ready to feed into your VAE Decode or next sampler stage.

How to install it

Through ComfyUI Manager: search crystools, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/crystian/comfyui-crystools.git
cd comfyui-crystools
pip install -r requirements.txt

You'll find it under crystools πŸͺ› / Switch afterward. No models, no GPU dependency for this specific node - it's just boolean plumbing.

Common issues & troubleshooting

Honestly, there's not much to go wrong with a node this small. The one thing worth flagging for beginners: both on_true and on_false are required inputs, not optional - ComfyUI won't run the graph if either socket is left unconnected, even if you're only planning to ever use one branch. If you're prototyping and only have one latent source ready, you still need to plug something into the other slot (even a throwaway Empty Latent Image) or the queue will refuse to start.

The good news is you don't need to worry about the switch wasting compute on the branch you didn't pick: Crystools added "lazy switches" in version 1.24.0, using ComfyUI's lazy-evaluation support so the switch only triggers execution of whichever branch the boolean actually selects. Feed on_true from a cheap Empty Latent Image and on_false from an expensive upscale pass, flip the boolean to true, and the expensive branch simply doesn't run. That's worth knowing before you assume you need a separate bypass or group-muter just to avoid paying for both paths - with this node, you don't.

Categorycrystools πŸͺ›/Switch

Inputs (3)

NameTypeDefaultDescription
on_trueLATENTβ€”
on_falseLATENTβ€”
booleanBOOLEANtrueβ€”

Outputs (1)

NameTypeDescription
latentLATENTβ€”