🗂️Dict → ◯ANY-Key◯
For when your dict keys aren't strings
- dict
- key
- value
Almost every node in this pack treats keys as strings - you type a name, the node cleans it up, and the lookup happens by that name. DictExtractAnyKey ("🗂️Dict → ◯ANY-Key◯") is the deliberate exception: here the key itself can be any type at all. An int, a float, a boolean, a string - whatever you stored the value under, you can look it up by that exact object.
That sounds obscure until you hit the case that needs it. Dictionaries in Python allow non-string keys, and once you start building dicts programmatically - with Basic Data Handling's dict nodes, or by iterating a list and using an index as a key - you'll have a dict whose keys are integers, not words. A normal extractor would be useless there; this one just asks "give me whatever is under this key" and finds it.
What you set
- dict (required) - the dictionary to read from. Must be non-empty.
- key (optional) - the key, of ANY type. It's an optional input, so you can also leave it unconnected and let the value ride in on a wire from another node.
Output: value as ANY, no type checking on the way out either.
The trade-offs, straight
Two things you get by design: no key cleanup (there's no cleanup_key toggle here, because cleaning up an int or a bool makes no sense), and no output type check. If you extract with an ANY key, you're fully on the ANY highway - the value comes back untyped, so type mismatches will surface in whichever node consumes it, not here.
That makes this node the specialist of the family. The "string key → typed value" extractors cover 95% of real workflows, and DictExtractAny covers the "I don't care about the type" case. DictExtractAnyKey exists for the remaining sliver: when the key is the thing that's dynamic. If you've never stored a value under an integer key, you can probably skip it. If you have, it's the only node in the pack that will get it back.
How it works
Under the hood it reads the dict and does a plain dict[key] lookup - the same call any Python dict would make. Because keys are compared by equality, "seed" and seed (an int) are different slots, and lookup-by-exact-key is what saves you from collisions. The dicts here are immutable frozendicts, so sharing the wire across branches stays safe, and a missing key still raises a hard "No such key in Dict" error rather than returning nothing.
Install
Same story as every node in this pack - small, single dependency (frozendict), no models. ComfyUI Manager: search "Dict Tools". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Lex-DRL/ComfyUI-DictTools
Restart ComfyUI. The pack needs 0.18.0+ (newer extension API), so if nothing shows up after install, update ComfyUI before digging further. This one's niche, but when you need it, nothing else in the pack will do.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dict | DICT | A Dictionary to work with. | |
| keyopt | * | Key (of ANY type) for the item extracted from the dict. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | * | The actual any-type item extracted from the Dict. |