List Keys
List Keys — pull the keys out of a dict (or indices out of a list)
- obj
- keys
Hand a dict to listKeys and you get back its keys as a list. Hand it a list or tuple and you get back the indices. It's a two-line Python utility (list(obj.keys())) that lives in ovum/loop because it's most useful when you're doing structured iteration over dictionaries - which ComfyUI's graph makes surprisingly awkward without a node that converts a dict's keys into a fan-out-able list.
The type is * on both sides, so it's deliberately loose: any object in, a list out. What it does depends on what you give it, straight from the source:
- dict →
list(dict.keys())- the actual keys, in insertion order. - list or tuple →
list(range(len(obj)))- positions0, 1, 2, ...up to the length. - anything else → an empty list, gracefully, rather than crashing.
When this actually helps
ComfyUI's native data types are tensors and strings; Python dicts usually show up when you're working with embedded workflow metadata, image-ex context objects, or API-style payloads. If a node hands you a dict and you want to iterate over its entries - say, every key in a metadata blob - listKeys gives you the list to loop over, and the pack's listValues gives you the matching values in the same order. The classic pairing is listKeys + Get by Index inside a loop: for each key, pull the value.
It also behaves sensibly as a list-length helper in a pinch: feed it a list, get back [0..n-1], and the length is implied. (There's a dedicated GetListLength in the same category if you want the count explicitly.)
The pairing that matters
listKeys and listValues are two halves of the same trick, both in ovum/loop:
listKeys(obj)→["prompt", "workflow", "seed"](or[0, 1, 2]for a list).listValues(obj)→ the values in the same order.
Use them together when you need to zip keys and values through two parallel lists, or drive a loop over a dict without hand-typing the keys.
Install
Part of comfy-ovum, so one install covers it:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
or search comfy-ovum in ComfyUI Manager and restart. No models, no keys.
Gotchas
The output is a single * socket holding a list - if your downstream node expects a Comfy batch-style list of items rather than one list object, you may need a passthrough/cast node from this same pack to adjust how the list is treated. And remember it's not a "length" node: feeding it a string returns an empty list, not an error, which can silently look like "no keys" if you wired it wrong.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| obj | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| keys | * | — |