Nodes/Basic data handling/create from items (LIST)
ComfyUI Node

create from items (LIST)

From a LIST of pairs to a dict — the pair-collector that round-trips

By StableLlama·Created about a year ago·Updated 4 days ago· 48
create from items (LIST)
  • items
  • DICT

"create from items (LIST)" builds a dictionary from a single Python LIST whose elements are key-value pairs. It's the LIST-flavored sibling of create from items (data list): same job, different input flavor. Where the data-list version eats ComfyUI's native per-item list, this one takes the pack's LIST type - one Python list object passed as a single variable, order preserved, duplicates allowed.

The distinction isn't academic. If you're assembling pairs from nodes that output a LIST - the pack's own items node, a create LIST, a string split - this is the node whose port will actually accept them. Try to feed a LIST into the data-list version and the sockets won't match.

How it works

One required input, items (LIST). On execution it validates that every element is a two-element pair, then builds the dict with dict(items). Because the whole list arrives at once (this node is not INPUT_IS_LIST), order in is order processed - which matters for the classic round-trip pattern below.

Inputs and outputs

  • items (LIST) - the list of (key, value) tuples.
  • Output: DICT - the assembled dictionary.

The round-trip trick that makes it shine

Pair this with the pack's items node (which turns a dict into a LIST of pairs) and you get a serializable loop: dict → items → LIST of pairs → this node → same dict. That's genuinely useful for intermediate storage - hand the LIST to a node that writes or transforms pairs, then reconstruct the dict on the other side. The pack's get keys values node gives you a similar two-list route for keys and values separately.

Gotchas

Same pair-validation rule as its twin: any two-element item is accepted, so a stray two-character string becomes a weird {char: char} entry. And a duplicate key isn't an error - later pairs silently overwrite earlier ones, which is standard dict behavior but easy to trip over when pairs come from multiple sources. If your values need typing (ints, floats, booleans) rather than whatever the pairs carry, use the type-specific create nodes instead.

Install

Part of Basic data handling - pure Python, no dependencies, no model downloads. Install via ComfyUI Manager (search "Basic data handling") or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

then restart ComfyUI. It's a small node, but it's the one that makes dict round-trips through LIST possible - keep it in mind when you need to hand a dict's contents to a node that only speaks lists.

CategoryBasic/DICT

Inputs (1)

NameTypeDefaultDescription
itemsLIST

Outputs (1)

NameTypeDescription
DICTDICT