ComfyUI Node

get

Pull a value out of a dict without crashing when the key's missing

By StableLlama·Created about a year ago·Updated about 15 hours ago· 48
get
  • input_dict
  • default
  • value
key

"get" is the dictionary's other half: the node that pulls a single value back out by key. After you've built a dict with create DICT, merged it, filtered it, or received it from another node, this is how you retrieve one field. It's the most-used accessor in the pack's DICT section, and for good reason - it's the safe version of indexing, the one that doesn't blow up when the key you asked for isn't there.

Where Python's raw dict["key"] raises a KeyError on a miss, this node behaves like dict.get(): missing key + a default → default; missing key + no default → None. In a visual graph where a disconnected port can mean "this value was never set," that resilience is the whole point. Your workflow keeps running and the downstream node sees a graceful None instead of a red error box.

How it works

  • input_dict (DICT) - the dictionary to read from.
  • key (STRING, default "") - which key to fetch.
  • default (*, optional) - what to return if the key is missing.
  • Output: value (*) - the retrieved value.

The output is type *, so it'll wire into almost any port - text, number, dict, whatever the stored value was. That's flexible, but it's also the main thing to sanity-check: ComfyUI won't enforce that the value you retrieve is what a downstream node expects, so a None from a miss can flow somewhere that later chokes on it.

The practical pattern

  • Use default when a missing value is meaningful - e.g., return 0 for an optional count so downstream math doesn't hit None.
  • Leave default unset when None is the honest answer - "this setting doesn't exist in this dict."
  • For several keys at once, use get multiple; for a whole dict's worth, get keys values.

A small gotcha

The key input is a plain string widget, so you type the key literally. There's no dropdown of the dict's actual keys - the node can't know them at edit time. If you misspell a key, you don't get an error; you get the default (or None), which can be confusing until you remember to check. When debugging, that's the first thing to suspect: right node, wrong spelling.

Install

Part of Basic data handling - pure Python, zero dependencies, no model downloads. 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 that does one thing, but it's the one you'll reach for every time a dict needs to come back apart.

CategoryBasic/DICT

Inputs (3)

NameTypeDefaultDescription
input_dictDICT
keySTRING
defaultopt*

Outputs (1)

NameTypeDescription
value*