pop
Pop one entry out — get the value AND the trimmed dict back
- input_dict
- default_value
- dict
- value
"pop" removes one entry from a dictionary and returns two things: the value that was removed, and the dict with that entry gone. It's the pack's version of Python's dict.pop(), and the two outputs are the reason it exists - most removal nodes only give you back the modified dict. Pop gives you the value and the rest, so you can pull a field out, use it, and keep the trimmed dict all in one move.
The classic pattern: you have a config dict, one of its keys needs special handling (log it, transform it, send it somewhere), and you don't want that key continuing on with the dict. Pop extracts it and hands you the value to work with while the remaining dict goes on its way.
How it works
input_dict(DICT) - the dictionary to pop from.key(STRING, default"") - which entry to remove.default_value(*, optional) - the fallback if the key isn't found.- Output
dict(DICT) - the dictionary with the entry removed. - Output
value(*) - the removed value (or the default).
Two behaviors worth knowing precisely:
If the key is found, it's removed from a copy and you get the value back. Non-destructive to the input - the original dict is untouched, which matters in ComfyUI where one output feeds many consumers.
If the key is missing, you get the original dict back unchanged, and the value output is your default_value - or None if you didn't provide one. Note the node's description claims a missing key errors, but the actual code doesn't raise: it returns gracefully. Missing keys are a silent None, not a crash.
Gotchas
- A missing key with no default silently yields
None- if you later wire thatvalueinto something that expects a real value, you'll be debugging a phantomNone. If missing keys are meaningful, always supply adefault_value. - The
keyis a string widget, not a dropdown of the dict's keys. Misspell it and you get the default path, not an error. - You're removing by exact key name only - there's no "pop the last entry" mode here. For that, the pack's
pop item/pop randomnodes exist.
When to reach for it
Any time you need to both extract a value and slim down a dict for downstream. Pull the seed out of a settings dict to log it while the rest flows on; take a field you've consumed and keep it out of a save payload.
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 the rare node that changes a dict and hands you the change - use the two outputs together and it's a genuinely useful move.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_dict | DICT | — | |
| key | STRING | — | |
| default_valueopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| dict | DICT | — |
| value | * | — |