🗂️Dict → Mask🟢
Masks in the bus, applied where they matter
- dict
- value
Masks are how ComfyUI knows where to do things - which region to inpaint, which part to composite, which area a ControlNet preprocessor should focus on. They're also awkwardly heavy to trace in a busy graph: a mask can be generated in one corner (from a segmentation node, a manual edit, an image-to-mask conversion) and consumed two screens away. DictExtractMask ("🗂️Dict → Mask🟢") is how a mask travels in the dict bus and comes out at the consumer.
The pattern that clicks here is the inpaint/refine pipeline. Generate or load your mask, store it in the dict under mask_faces or mask_regions, and let the inpaint node, the compositor, and the detailer each extract the region they need. One source of truth for the mask means you edit it once and every consumer follows - instead of remembering which of four mask wires you actually updated.
What you set
- dict (required) - the dictionary to read from (non-empty).
- key - the slot name, e.g.
mask_main. - cleanup_key (on by default) - normalizes the key.
Output: value as MASK, wired into inpaint nodes, compositing, conditioning, or anything that takes a mask input.
Why it's a good citizen
Masks are batch-shaped tensors, and the immutable frozendict behavior means the shared mask wire is safe to fan out to several consumers - the inpaint pass and a preview can both read it without clobbering each other. Combined with keyed slots, your mask handling becomes legible: you can see at a glance which masks a workflow is working with, rather than reverse-engineering it from a pile of green wires.
The extractor type-checks on the way out, so a mis-stored slot (an image where you promised a mask) fails with a clear error instead of a composite doing something baffling. And a missing key raises "No such key in Dict" rather than silently returning nothing - with masks, a silent empty mask usually means an accidental full-image edit, so the loudness genuinely saves you.
Install
Same for every node in this pack - small, one lightweight dependency (frozendict), no model downloads. ComfyUI Manager: search "Dict Tools". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Lex-DRL/ComfyUI-DictTools
Restart ComfyUI. Needs 0.18.0+ (newer extension API) - if the nodes don't appear after install, update ComfyUI before anything else.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dict | DICT | A Dictionary to work with. | |
| key | STRING | Key (name) of the item extracted from the dict. | |
| cleanup_key | BOOLEAN | true | Automatically remove leading/trailing spaces and extra newlines from the key. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | MASK | The actual Mask-type item extracted from the Dict. |