VAE Encoder (Switch)
VAE Encoder (Switch)
- pixels
- vae
- LATENT
This is the stock VAEEncode node with one thing bolted on: a boolean that lets you kill it without touching a single wire. The README's own description is blunt about it - "modified the official VAEEncoder node by adding a switch. When turned off, it will return None." That's the whole node.
Why that's worth a dedicated custom node instead of just deleting the VAEEncode and rerouting: the VAE is the codec that turns pixels into the latent space diffusion actually runs in - every img2img and inpainting pass needs one, but not every run of a given workflow does. If you're building one graph that sometimes does pure text-to-image and sometimes does image-to-image off a reference photo, you normally end up either maintaining two separate graphs or physically rewiring a bypass every time you switch modes. VAEEncoderSwitch lets you leave the graph wired exactly as it is and flip one toggle to turn the encode step on or off. It's the same pattern the pack applies to half a dozen other stock nodes - LoadImageWithSwitch, ImageCompositeMaskedWithSwitch, CheckpointLoaderSimpleWithSwitch - a family of "official node plus kill switch" utilities.
Inputs: pixels (an IMAGE) and vae (a VAE) are required, exactly like the stock node. enabled (default true) is the only addition - set it to false and encoding is skipped entirely.
Output: a single LATENT. This is the part to actually pay attention to: when enabled is false, the README states the output is None, not an empty or placeholder latent. That matters because whatever you wire this into downstream - a KSampler, a LatentUpscale, anything expecting an actual latent tensor - needs to either tolerate a None input or be routed around when you flip the switch off. This isn't a node you can leave permanently disabled in a graph that has no alternative latent source feeding the same slot; it's built for conditional branches where something else (an EmptyLatentImage, say) is also feeding that input path depending on the same toggle.
Install: search "ComfyUI-utils-nodes" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI. No models, no API keys - this is pure graph logic sitting on top of a node ComfyUI already ships.
Common issues:
- The VAE you feed in still has to match the checkpoint's training, same as with the stock node - this switch doesn't change VAE compatibility rules at all. A mismatched VAE gives you the classic washed-out or noisy decode regardless of whether you got here through the vanilla node or this one; there's no superior VAE in the abstract, only the one the checkpoint actually trained against.
- If your downstream sampler errors out with something like a missing or
NoneTypelatent the moment you toggleenabledoff, that's expected behavior per the README, not a bug - you need conditional routing on the output side too, not just the input side. - Like every encode/decode round trip, running this repeatedly in a chained pipeline (multiple img2img passes) is lossy - each pass through a VAE degrades detail a little. That's inherent to VAEs generally and not specific to this node, but it's worth remembering if you're chaining several encode steps back to back instead of compositing intermediate results.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| enabledopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |