ToDict (Yogurt Nodes)
Turn key-value pairs into a real dictionary, with a safety net for missing values
- data
- default_value
- dict_result
Dictionaries are ComfyUI's quiet backbone - the pack's JSON nodes, its dict operations, and half the config plumbing in advanced workflows all speak in key-value pairs. The trouble is getting data into dict shape. YogurtToDict takes "pairs (list of tuples) or mapping" and converts them into a proper dictionary, which is a sentence that sounds abstract until you're staring at a list of tuples from a split operation and need a dict for JsonStringify or a DictGet lookup.
How it works
Required input: data, typed *. It accepts either a mapping (dict-like, passes through) or a list of key-value pairs - the kind of thing you'd assemble with YogurtDictFromLists or by pairing lists together. Output is a single dict_result.
Where it gets interesting is the two optional inputs:
use_default(BOOLEAN, default false) - when true, pairs that are missing a value get filled in.default_value(*) - the value used to fill those gaps.
So if you hand it [["width", 512], ["height"]] with use_default on and default_value set to 0, you get {"width": 512, "height": 0} instead of a malformed entry. That's the "safety net for incomplete pairs" the tooltip promises, and it's genuinely useful when you're parsing ragged input - CSV-ish data where some rows have fewer fields than others.
When you'll actually reach for it
The realistic case is feeding JSON-oriented nodes. The pack's JsonStringify wants a dict to serialize; JsonValidate wants dict-shaped data; DictGet and DictContainsKey want something to look inside. If you've got pairs scattered across the graph, this is the collection point. It also plays well with the pack's list utilities - split a config line on commas, turn the alternating fields into pairs, and build a dict on the fly.
Installing it
It's part of the Yogurt Nodes pack under YogurtNodes/Logic - one install for everything:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Or use ComfyUI Manager and search "ComfyUI-YogurtNodes." Restart, done. No models, no keys.
Gotchas
The main one: it converts, it doesn't validate. If your input isn't actually pairs-shaped - say, a flat list of strings - you won't get a clean dict out, and the schema doesn't promise what happens. Feed it well-formed pairs and keep use_default handy for the ragged cases. And remember dict_result is *-typed, so it'll connect to a lot of things that may not want a dict; when in doubt, run it through a node that explicitly takes dict input before building your chain.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| data | * | Pairs (list of tuples) or mapping to convert to dict | |
| default_valueopt | * | Default value for keys without values | |
| use_defaultopt | BOOLEAN | false | Use default value for incomplete pairs |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dict_result | * | — |