Nodes/Tojioo Passthrough/Any Latent Switch
ComfyUI Node

Any Latent Switch

Which latent feeds the sampler? Slot order decides

By Tojioo·Created 11 months ago·Updated 7 months ago· 13
Any Latent Switch
  • latent_1
  • latent

Any Latent Switch picks the first connected LATENT and feeds it to the latent output - decided by slot order, not a selector. In every image workflow there's a moment where the sampler needs "a latent", and there are usually several candidates for what that latent should be: a fresh empty latent at one resolution, an image encoded to latent, a latent carried from an earlier pass. This node is how you let the wiring choose.

It's the first-non-null switch pattern the community knows from rgthree's Any Switch, but typed: the sockets only accept LATENT, so there's no wildcard guessing and no way to plug an image in sideways.

How it works

Start with latent_1; wire another latent source and a latent_2 slot grows. At execution it collects every connected input that isn't None and returns the lowest-numbered live one. Muted and bypassed upstream nodes deliver None - and those get skipped - so muting the branch that supplies latent_1 hands the job to latent_2 automatically. Connect nothing and it raises "no inputs connected" rather than returning an empty latent dict.

Where you'd use it

  • Empty vs. encoded. A fresh empty latent as the default, an img2img latent when you drop an image in.
  • Multi-resolution presets. Two empty latents at different sizes, one sampler downstream, mute whichever you don't want.
  • Pass routing. A latent from an earlier sampling stage vs. a fresh one for a refinement pass.

Install

ComfyUI Manager → search "Tojioo Passthrough" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Tojioo/tojioo_passthrough.git

Restart ComfyUI. No models, no pip dependencies - the pack is lean Python plus a bundled frontend and lives on the Comfy Registry under publisher tojioo.

Common issues

Slot order is the only real rule: a live latent_1 always beats latent_2, so if the sampler gets the "wrong" resolution, check the earlier slot's upstream for a mute or bypass - that's your switch. This node selects one latent; if you want to stack several latents into a single batch for batch generation, that's Any Latent Batch Switch instead. And keep a slot connected - an empty switch errors on the canvas rather than quietly returning nothing.

CategoryTojioo Passthrough/Dynamic Nodes/Switch Nodes

Inputs (1)

NameTypeDefaultDescription
latent_1optLATENT

Outputs (1)

NameTypeDescription
latentLATENT