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

DictSubset (Yogurt Nodes)

Extract just the fields you need from a dict

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
DictSubset (Yogurt Nodes)
  • dict_data
  • keys
  • subset
ignore_missingfalse

DictSubset is the "projection" node for dictionaries: you give it a dict and a list of keys, and it returns a new dict containing only those key-value pairs. Think of it as DictFilter but with an exact list instead of a regex - if you know precisely which fields you need, this is the sharper tool.

The most common use is schema narrowing. An LLM or an API hands you a fat dict with 30 fields; downstream you only need width, height, and seed. Pass in the keys list ["width", "height", "seed"] and you get a lean dict you can inspect, log, or hand to a node that expects a specific shape. It's also great for building the exact payload a template wants, or for hiding the noise when you're previewing data in a workflow.

The one behavioral decision that matters is ignore_missing. Off (default), the node raises an error the moment you request a key that doesn't exist - strict mode that catches typos and schema drift fast. On, it silently skips missing keys and returns the subset that does exist. For data you control, strict is better; for unpredictable LLM/API output, forgiving is what keeps the graph alive.

How it works

Straightforward Python: it iterates your keys list and builds a new dict from dict_data[key], skipping keys (or erroring) according to ignore_missing. The keys input is *-typed and expects a list-like object - the output of DictKeys or any list node works directly. Your original dict is never modified.

Inputs

  • dict_data - the dictionary to extract from.
  • keys - a list of the keys you want (a *-typed list-like).
  • ignore_missing - default false; skip absent keys instead of raising.

Output

  • subset - the new dict with only the requested pairs, *-typed.

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. Under "Yogurt Nodes" → Logic.

Common issues

  • "It crashed: key not found" - ignore_missing is off and one of your keys isn't there. Either enable it or check the key spelling with DictKeys.
  • "My subset is empty" - either your keys list is empty or none of the keys exist. Feed it a verified keys list.
  • "I wanted to filter by pattern, not by list" - that's DictFilter. This node is for exact-key extraction.

The mental model: DictSubset for "I know the schema," DictFilter for "I only know the pattern." Together they cover most "get the useful part out of this blob" work.

CategoryYogurtNodes/Logic

Inputs (3)

NameTypeDefaultDescription
dict_data*Any dict-like object
keys*List of keys to extract (list-like object)
ignore_missingoptBOOLEANfalseSkip keys that don't exist instead of raising error

Outputs (1)

NameTypeDescription
subset*