🟣Latent → Dict🗂️
Keep Your Latents Off the Spaghetti Heap
- dict
- value
- dict
Latents are the intermediate currency of ComfyUI - the compressed tensor representation between VAE Encode and VAE Decode - and a serious workflow can have several floating around at once: the base latent, the upscaled one, the denoised result. DictAddLatent lets you bundle one into your dict under a named key, so you're not guessing which purple wire goes where when the graph gets big.
The LATENT value is a wired input, coming from an Empty Latent Image, a VAE Encode, or a sampler's output. Like the other media-type Add nodes it's validated before storage, then handed back as part of a fresh dict.
How it works
Same Dict Tools engine as the rest of the pack: check the value is really a LATENT (a dict holding samples and noise-related fields), store it under your key, return a new frozendict without touching your input. Keys sort alphabetically on update, which is by design.
The genuinely useful angle here is multi-stage sampling. Put the first-pass latent in the dict along with your seeds and denoise settings, extract it at the next sampler stage, and the whole pipeline's state travels as one object. It's the "bus" idea from the README applied to the thing that actually carries the image.
The inputs that matter
- key (STRING) - the name you'll fetch the latent back by.
- cleanup_key (BOOL, default on) - trims spaces/newlines from the key.
- dict (DICT, optional) - an existing dict to extend, or empty to start one.
- value (LATENT, optional) - the wired latent from your encoder or sampler.
Output is dict (DICT). Get it back out with DictExtractLatent.
Install
ComfyUI Manager: search Dict Tools, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Lex-DRL/ComfyUI-DictTools
Restart after. Only dependency is frozendict, handled by Manager.
Gotchas
Pack-wide: needs ComfyUI 0.18.0+ (newer node API). Failed to load → update ComfyUI.
Latent-specific gotcha: latents are genuinely easy to confuse with images in a busy graph, and this node won't accept an image where it expects a latent. The error is loud and clear though - "Value isn't a <Latent> instance." Also remember the dict holds a snapshot: extract the latent, run more sampling on it, and the copy in the dict is still the old state. Re-add it if you want the bus to carry the updated version.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| key | STRING | Key (name) of the item inserted into the dict. | |
| cleanup_key | BOOLEAN | true | Automatically remove leading/trailing spaces and extra newlines from the key. |
| dictopt | DICT | An (optional) Dictionary to work with. | |
| valueopt | LATENT | The actual Latent-type item to add into the Dict. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dict | DICT | — |