ComfyUI Node

keys

Just the key names, please — a dict's labels as a LIST

By StableLlama·Created about a year ago·Updated 4 days ago· 48
keys
  • input_dict
  • LIST

"keys" extracts a dictionary's key names into a LIST. That's the whole job: dict in, list of keys out, nothing else. You'd reach for it when you need to know what a dict contains - to iterate its field names, check membership, feed the names to a selector or formatter, or debug what's actually in the dict at that point in the graph.

It's the simplest node in the DICT section, and its simplicity is the point. When a dict arrives from elsewhere (a merge, a filter, an upstream node), the keys list is your inventory of what's inside. It's also the honest answer to "which node do I use when I only want the names?" - get keys values gives you keys and values together, but if values are noise, this one is cleaner.

How it works

  • input_dict (DICT) - the dictionary.
  • Output: LIST - the keys, in insertion order.

Under the hood it's list(dict.keys()). Order is the dict's insertion order (Python 3.7+), which is the order you built it in - create DICT adds pairs top to bottom, so that's the order you get back.

Where it fits

  • Membership checks: feed the keys list into a list contains node to ask "does this dict have a key called X?" - the pack's own contains key node does this directly, but via LIST you can compose it with anything else list-shaped.
  • Iteration: drive a per-key loop by handing the keys list to a batch or iterate node.
  • Debugging: dump the keys to a text/display node to see at a glance what a dict holds, before you go hunting for a specific value.

A small honest note

This node and values and get keys values overlap a lot, and you won't go wrong picking any of them. If you only need names, keys is the least overhead. If you need names and values aligned, get keys values. If you want pairs that stay glued together, items. Knowing the difference comes down to one question: what are you doing next with the result?

Install

Ships in 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 boring little node that earns its keep every time you need to know what a dict is carrying.

CategoryBasic/DICT

Inputs (1)

NameTypeDefaultDescription
input_dictDICT

Outputs (1)

NameTypeDescription
LISTLIST