Nodes/ComfyUI-YogurtNodes/DictFromLists (Yogurt Nodes)
ComfyUI Node

DictFromLists (Yogurt Nodes)

Two lists in, one dict out — with an escape hatch for ragged lists

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
DictFromLists (Yogurt Nodes)
  • keys
  • values
  • fill_missing
  • dict_result
use_fillfalse

DictFromLists is the constructor of the dict family: give it a list of keys and a list of values, and it zips them into a dictionary. It's the node you reach for when your data arrives as parallel lists - which happens constantly once you're parsing CSV-ish output, aligning two batch results, or pairing model names with their file paths from a Glob Files result.

The mechanism is exactly Python's zip(), and the one detail worth understanding is what happens when the two lists aren't the same length. By default the node keeps only the overlapping portion - if you have 5 keys and 3 values, you get a 3-entry dict and 2 keys silently vanish. That's the "safe" default that never errors, but it can silently drop data. Flip use_fill on, though, and it changes behavior: the shorter list gets extended to the longer one's length - missing values become your fill_missing value, and missing keys get auto-generated as key_0, key_1, etc. So you can either truncate to the overlap or pad to the full length, depending on which failure mode you'd rather have.

The padded-key behavior is the sneaky bit worth knowing: if values is longer than keys and use_fill is on, you don't just get extra values - you get synthetic keys named key_0, key_1... If that's not what you want, make sure your keys list is the longer (or equal) one.

Inputs

  • keys - list of keys.
  • values - list of values.
  • fill_missing - the value used for missing entries when use_fill is on. *-typed, so it can be any type.
  • use_fill - the toggle between "truncate to overlap" (off) and "pad to full length" (on).

Output

  • dict_result - the built dictionary, *-typed so it feeds into any of the pack's other dict nodes or anything that takes a dict.

Install

Ships in ComfyUI-YogurtNodes:

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

Or via ComfyUI Manager (search "YogurtNodes") and restart. It's under "Yogurt Nodes" → Logic.

Common issues

  • "Keys are missing from my dict" - lists were different lengths and use_fill was off; the extras got dropped. Turn on use_fill or equalize the lists.
  • "I got key_0, key_1 out of nowhere" - use_fill on with a longer values list. Check which list is longer.
  • "It won't accept my input" - the inputs are *-typed, so make sure you're actually feeding lists (a ToList node can coerce iterables) rather than a single value.

It's a simple node with a deceptively important length-mismatch decision hidden inside. Get that one dial right and it slots cleanly between a data source and the rest of your dict logic.

CategoryYogurtNodes/Logic

Inputs (4)

NameTypeDefaultDescription
keys*List of keys
values*List of values
fill_missingopt*Value to use for missing values if lists are different lengths
use_filloptBOOLEANfalseUse fill value for missing entries

Outputs (1)

NameTypeDescription
dict_result*