to DICT
Getting structured data into a DICT when the socket won't take it
- input
- DICT
Some nodes hand you a Python dict and expect one back, and some hand you the same data in a shape that's not a dict - a list of key-value pairs, say - and the connection won't happen. to DICT is the converter for that gap: it takes a compatible input and produces a proper DICT type. It's part of Basic data handling, StableLlama's zero-dependency pack, and it's honestly the most niche of the pack's cast nodes - you'll use to INT and to FLOAT all the time, but you'll reach for this one only when a workflow starts moving structured data around.
How it works
The conversion is Python's dict(input), and that's where the constraints come from. A dict can only be built from:
- a mapping - something that's already dict-like, or
- an iterable of key-value pairs - e.g. a list of two-element pairs like
[["name", "Anna"], ["steps", 30]].
Anything else fails, and the node fails loudly: it catches the invalid case and raises a ValueError with a message telling you the input must be a mapping or a list of key-value pairs. That's good behavior, honestly - a silent garbage dict would be worse. What you can't feed it: a plain list of scalars, a string, a number. Those have no key-value structure, and no amount of wishing will make one.
The input and the output
input(ANY) - the mapping or list of pairs to convert.DICT(output) - the resulting dictionary.
That's the whole node. Downstream, whatever expects a DICT socket will accept it; the pack's dict nodes (get, set, keys, values, merge...) are the natural consumers.
Installing it
Install Basic data handling from ComfyUI Manager (search "Basic data handling"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI. No dependencies, no model files.
Troubleshooting
- "It throws 'Cannot convert... to a DICT'." Expected when the input isn't a mapping or a list of pairs. The most common real-world case: someone built a list of plain values and expected a dict to materialize. A dict needs keys and values - if your data has no keys, it genuinely isn't dict-shaped, and you should restructure upstream rather than fight the cast.
- "I fed it a list of pairs and it still failed." Check the pairs are actually two elements each - a single-element pair or a ragged list breaks
dict(). Also, duplicate keys don't error, they just silently keep the last one, which is worth knowing when you're debugging a missing value. - "I wanted a JSON string, not a dict." Different conversion. This node produces the DICT object type, not a string. Look at the pack's string or regex nodes (or a JSON utility pack) if you need serialized text.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DICT | DICT | — |