Nodes/ComfyUI-JakeUpgrade/Latent Input Switch JK๐Ÿ‰
ComfyUI Node

Latent Input Switch JK๐Ÿ‰

Pick between two latents without tearing up the graph

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Latent Input Switch JK๐Ÿ‰
  • latent_false
  • latent_true
  • latent_output
  • boolean
โ—„boolean_valuefalseโ–บ

Latent Input Switch JK is the latent-flavored member of JakeUpgrade's input-switch family. A BOOLEAN picks between two LATENT values and the winner flows out. If you've read the Image Input Switch JK article, you already know the pattern - this is the same node with the type swapped to latents.

How it works

boolean_value selects between latent_true and latent_false. True plus a connected latent_true returns the true latent; every other case - false, or true with latent_true disconnected - returns latent_false. That optional-input trap is worth remembering across the whole family: an unconnected true input means the true branch silently never happens.

Latents are the encoded representation of images before the VAE decode, and switching them has one property image switches don't: the unselected path still gets computed upstream. ComfyUI builds everything feeding both inputs, so if your false branch runs a full second sampling pass just to be discarded, you've paid for it. Use latent switches to route cheap-to-produce latents - an empty latent, a scaled latent, a noise-injected one - not to "conditionally skip" an expensive pass.

Inputs and outputs

  • boolean_value - the condition.
  • latent_false - required, returned when false (or when true with the true input unconnected).
  • latent_true - optional, returned when true and connected.
  • latent_output - the chosen LATENT.
  • boolean - the condition passed through, handy for chaining switches or gating a VAE decode on the same decision.

The natural use: toggle between an Empty Latent Image (fresh generation) and a VAE Encoded latent (img2img or a prior result) feeding one KSampler. Or route between two resize strategies before sampling.

Installing it

Ships in ComfyUI-JakeUpgrade:

  • ComfyUI Manager โ†’ search "JakeUpgrade" โ†’ install โ†’ restart.
  • Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
cd ComfyUI-JakeUpgrade
pip install -r requirements.txt

Windows portable: run install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt.

Common issues

  • True branch never fires - the disconnected-latent_true footgun again. Check the input before debugging anything else.
  • Wrong latent shape downstream. A latent carries spatial dimensions that encode into the sampler. If you switch between an empty latent at 512 and one at 768, downstream nodes that assume a size will misbehave. Switch on shape-compatible latents, or size them deliberately.
  • Expecting it to save compute. It routes data; it doesn't skip execution. If the false path is a full sampler run, you're burning cycles regardless of which branch wins.

For what it is - a typed, boolean-controlled selector - it does the job cleanly, and its boolean pass-through is the quietly useful part that keeps the rest of your graph in sync with the choice.

Category๐Ÿ‰ JK/๐Ÿ”€ Switch

Inputs (3)

NameTypeDefaultDescription
boolean_valueBOOLEANfalseCondition to select between inputs (True=latent_true, False=latent_false)
latent_falseLATENTLatent to return when condition is False
latent_trueoptLATENTLatent to return when condition is True (optional)

Outputs (2)

NameTypeDescription
latent_outputLATENTโ€”
booleanBOOLEANโ€”