ComfyUI Node

pop item

Need something out of a dict, and want to know what you got? pop item's the one

By StableLlama·Created about a year ago·Updated 4 days ago· 48
pop item
  • input_dict
  • dict
  • key
  • value
  • success

Most dict nodes in ComfyUI quietly transform a dictionary and hand you a new one. pop item (class Basic data handling: DictPopItem) is the one that takes something out - and tells you exactly what it took. If you're building workflows that drain a dict one entry at a time, or that need to grab a stored value and remove it in one step, this is your node.

The name is borrowed from Python's dict.popitem(), and that's exactly what it runs. Give it a input_dict (a DICT, which means a dict built by this same pack - see below) and it removes one key-value pair, then hands back four outputs:

  • dict - the dictionary with that pair removed
  • key - the key that was popped, as a STRING
  • value - the value that was popped (ANY type)
  • success - BOOLEAN, True if a pair was removed

Here's the part that surprises people: the description says "arbitrary" key-value pair, but on modern Python dicts preserve insertion order, so popitem() actually removes the most recently added pair - last in, first out. You can't choose which one; you just get a pair and the node hands you its key and value so you know what to do with it.

The other thing worth knowing is the failure mode, because it's genuinely kind. If the dict is empty - or anything goes wrong - the node doesn't throw an error. It returns the dict intact, an empty string for key, None for value, and success = False. No red node, no crashed queue. You check the success output and branch on it, which is a lot nicer than a graph that silently dies at 2am.

Why you'd wire this into a workflow

The classic use is a "work queue" pattern. Build a dict of pending tasks (or prompts, or file paths) with DictCreate, then pop items off one at a time. Since dict stays as a DICT you can feed it right back into the same node, draining it entry by entry. The key and value outputs feed downstream logic - and success tells you when you've finally emptied it.

One gotcha to keep in mind: DICT is a custom data type, not a native ComfyUI socket type. ComfyUI ships with primitives like INT, FLOAT, STRING - dicts aren't one of them. This pack defines DICT (and LIST, SET) as its own types, so a DICT output only plugs into other nodes that speak DICT, which in practice means other nodes in this pack. If you need to get data out of ComfyUI's world, run it through this pack's cast or DictGet/DictItems nodes instead of expecting a DICT to flow into a standard node.

Installing it

This node ships in the Basic data handling pack by StableLlama. Easiest route is ComfyUI Manager - search "Basic data handling", install, restart. Or from a terminal:

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

then restart ComfyUI. That's genuinely it: the pack declares zero dependencies, has no requirements.txt, and downloads no models. It's plain Python that mirrors what you already know from the language.

Troubleshooting

If success is coming back False and you expected a pair, check whether your dict actually has anything in it - an empty dict is the one real failure mode here. And if you keep popping the "wrong" item, remember the LIFO behavior: modern dicts pop the newest key, so if you want a random one, reach for this pack's pop random instead. That node takes a seed, so you can make the pick reproducible when you need to debug.

CategoryBasic/DICT

Inputs (1)

NameTypeDefaultDescription
input_dictDICT

Outputs (4)

NameTypeDescription
dictDICT
keySTRING
value*
successBOOLEAN