Nodes/WAS_Extras/VAEEncode (Bundle Latent)
ComfyUI Node

VAEEncode (Bundle Latent)

A VAE encode that ships its output inside the workflow file

By WASasquatch·Created 3 years ago·Updated 15 days ago· 43
VAEEncode (Bundle Latent)
  • vae
  • image
  • latent
tiledfalse
tile_size512
store_or_load_latenttrue
remove_latent_on_loadtrue
delete_workflow_latentfalse

Normal VAE encode, plus one trick: it can stash the resulting latent directly inside the workflow's own embedded metadata. That means if you share the workflow file (or a PNG with the workflow baked in), the "starting latent" travels with it - no separate .latent file to lose, no "here's the image, now go re-encode it yourself" step for whoever you send it to.

How it works

Point it at an image and a VAE and it encodes like any VAE Encode node. The difference is store_or_load_latent: with it on, the node writes the encoded latent into the workflow's metadata the first time it runs, and on later runs (or when someone else opens the same workflow file) it can load that stored latent back out instead of re-encoding from the image. That's the whole pitch - a "starting latent" that's portable inside the workflow itself, which matters most for the case in the README: sharing a workflow that depends on a specific starting latent, without also having to ship a loose file alongside it.

There's tiled encoding too, same idea as any tiled VAE encode: split a large image into tiles to keep VRAM down, at some cost to speed.

The inputs and outputs that matter

  • vae (VAE) - required, the VAE to encode with.
  • image (IMAGE, optional) - the image to encode. It's optional because if you're loading a previously-stored latent from the workflow metadata, you don't need a fresh image at all.
  • store_or_load_latent (default true) - the core toggle. On: store the latent into the workflow metadata if it's not there yet, or load it back out if it is.
  • tiled (default false) / tile_size (default 512, 320–4096) - standard tiled-encode knobs for large images on tight VRAM.
  • remove_latent_on_load (default true) - after loading a stored latent, delete it from the workflow so it doesn't sit there bloating the file on every subsequent save.
  • delete_workflow_latent (default false) - force-clear any stored latent before this run, if you want to guarantee a fresh encode regardless of what's cached.

Single output: latent (LATENT), same as any encode node - feed it to your sampler as usual.

How to install it

Via ComfyUI Manager: search "WAS_Extras", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/WAS_Extras

Restart ComfyUI. No extra dependencies for this node - it's plain torch/VAE work, same as core ComfyUI's own encode node.

Common issues & troubleshooting

A shared workflow keeps returning a stale latent instead of encoding your new image. That's store_or_load_latent doing exactly what it's for - once a latent is stored, the node prefers loading it over re-encoding. If you want a fresh encode from a new image, set delete_workflow_latent to true for that run, or turn store_or_load_latent off entirely.

Workflow file size keeps creeping up. A stored latent is real data sitting in your workflow's JSON. Leave remove_latent_on_load on unless you specifically need the latent to persist across many runs - otherwise every save keeps carrying that payload around.

Tiled encode looks seamy at tile boundaries or is unexpectedly slow. That's the standard trade-off with any tiled VAE encode, not specific to this node - smaller tile_size saves more VRAM but risks visible seams and costs more time; only turn tiled on when you're actually VRAM-constrained on a large image.

You just wanted a normal VAE encode. This node is a strict superset of that - leave store_or_load_latent off and it behaves like a plain encode with no metadata side effects.

Categorylatent

Inputs (7)

NameTypeDefaultDescription
vaeVAEVAE module used to encode the input image into latents.
tiledBOOLEANfalseEncode using tiled VAE to reduce VRAM usage.
tile_sizeINT512320–4096Tile size for tiled encoding (pixels).
store_or_load_latentBOOLEANtrueStore encoded latent into the workflow metadata or load an existing one if present.
remove_latent_on_loadBOOLEANtrueDelete the stored latent from workflow after loading it.
delete_workflow_latentBOOLEANfalseForce delete any stored latent in this node before encoding/loading.
imageoptIMAGEInput image to encode when not loading from workflow metadata.

Outputs (1)

NameTypeDescription
latentLATENT