Nodes/ComfyUI Essentials/πŸ”§ Mask From List
ComfyUI Node Runs on cloud

πŸ”§ Mask From List

Build a mask from a list of numbers you type or feed in

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,152
πŸ”§ Mask From List
  • values
  • MASK
β—„width32β–Ί
β—„height32β–Ί
β—„str_valuesβ–Ί

Most masks come from somewhere visual - a paint tool, a segmenter, a threshold. MaskFromList builds one from raw numbers instead. You give it a width and height and a flat list of values between 0 and 1, and it reshapes those values into a mask of that size. It's a niche tool, but when you want a procedural or scripted mask - a coarse grid you author by hand, or a mask driven by numeric output from another node - this is how you turn numbers into a MASK.

It's from ComfyUI Essentials by cubiq (Matteo Spinelli, the ComfyUI_IPAdapter_plus author). This is squarely in the "power user" corner of the pack; if you're not sure you need it, you probably don't yet.

How it works

You define the mask grid with width and height, then supply the cell values as a list. The node lays those values out across the grid - so a 4Γ—4 mask wants 16 values, in reading order - producing a MASK where each value sets that cell's intensity (0 = black/off, 1 = white/on). Because you can pass the values either as a real list from upstream or as typed text, it works both for hand-authored masks and for masks generated programmatically elsewhere in the graph.

The inputs and outputs that matter

  • width / height (INT, default 32, step 8) - the mask dimensions.
  • values (optional, wildcard) - a list of numbers (0–1) fed from another node. Use this when the values come from upstream.
  • str_values (optional, multiline string) - the same values typed by hand, e.g. comma- or newline-separated. Use this when you're authoring the mask yourself.
  • MASK (output) - the assembled mask, ready for compositing, inpainting, or attention masking.

How to install it

ComfyUI Manager: search ComfyUI Essentials, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/ComfyUI_essentials
pip install -r ComfyUI_essentials/requirements.txt

then restart. No models.

Common issues & troubleshooting

My mask came out wrong / errored on the count. The number of values has to fit the grid - width Γ— height cells. Give it too few or too many and the reshape won't line up. Count your values against the dimensions.

Which input do I use, values or str_values? Use values when the numbers arrive as a list from another node; use str_values when you're typing them. Don't fill both for the same mask - pick the source that matches where your numbers come from.

The mask is low-res and blocky. That's inherent - you're defining it cell by cell, so a 32Γ—32 mask has 32Γ—32 hard cells. If you need a smooth mask at that scale, feed the result through MaskSmooth to blur the blocks into a gradient.

Node missing after a Comfy update. Essentials is maintenance-only as of April 2025; pack nodes have broken on newer ComfyUI. Update through Manager, or roll back Comfy if it's genuinely incompatible.

Categoryessentials/mask

Inputs (4)

NameTypeDefaultDescription
widthINT320–16384β€”
heightINT320–16384β€”
valuesopt*00–1β€”
str_valuesoptSTRINGβ€”

Outputs (1)

NameTypeDescription
MASKMASKβ€”