Nodes/ComfyUI-Visionatrix/Dictionary New
ComfyUI Node

Dictionary New

Build a key-value dict with up to nine pairs, by hand

By Visionatrix·Created 2 years ago·Updated about a year ago· 3
Dictionary New
    • DICT
    key_1
    value_1
    key_2
    value_2
    key_3
    value_3
    key_4
    value_4
    key_5
    value_5
    key_6
    value_6
    key_7
    value_7
    key_8
    value_8
    key_9
    value_9

    VixDictionaryNew is the honest way to build a dictionary when you don't have one already: nine key/value text pairs, typed in by hand, one DICT output. It's part of the small dictionary toolkit the ComfyUI-Visionatrix pack ships - along with VixDictionaryConvert, VixDictionaryGet and VixDictionaryUpdate - and it's the entry point for anyone who wants structured data flowing through a graph.

    Why would you want a dict in a ComfyUI workflow? Because a single DICT wire can carry several related values at once: model settings, prompt fragments, metadata, whatever. Build it once, pass it around on one wire, and pull individual values out later with VixDictionaryGet. It's not a headline feature - but it's the node the rest of the toolkit builds on.

    Inputs

    • key_1 and value_1 are required; key_2 through key_9 with their matching value_2 through value_9 are optional. So the minimum is one pair and the maximum is nine.

    The important behavior is in the construction: pairs with an empty key are silently dropped. So leave unused slots blank (both the key and the value) and they just don't appear in the output. Keys are plain strings, values are plain strings - if you want typed values, that's not this node's job.

    Outputs

    One DICT output containing the filled-in pairs, in order. Feed it into VixDictionaryGet to look things up, VixDictionaryUpdate to merge it with another dict, or any DICT-consuming node.

    How it works

    The source builds a Python dict from the nine candidate pairs and filters out any with a falsy key. Nothing clever, nothing hidden - which is exactly what you want from a build-by-hand node. The trap to keep in mind is that the same key defined twice means the later pair wins, because that's how dict construction works.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Visionatrix/ComfyUI-Visionatrix
    

    Restart ComfyUI, or install ComfyUI-Visionatrix via ComfyUI Manager. No model downloads; the deps (torch, pillow, numpy) are already present.

    Gotchas

    The main thing that trips people up is expecting typed values. Everything here is a string, so if you store "0.5" you'll get back the string "0.5" - any numeric node you feed it to will need to handle that (most convert, but not all). Second, remember the empty-key-dropping rule works in your favor, but an empty value with a filled key is kept as an empty string. And nine pairs is the ceiling - if you genuinely need more, build two dicts and merge them with VixDictionaryUpdate. For most uses - a handful of named settings traveling on one wire - this is the node you want.

    CategoryVisionatrix/Text

    Inputs (18)

    NameTypeDefaultDescription
    key_1STRING
    value_1STRING
    key_2optSTRING
    value_2optSTRING
    key_3optSTRING
    value_3optSTRING
    key_4optSTRING
    value_4optSTRING
    key_5optSTRING
    value_5optSTRING
    key_6optSTRING
    value_6optSTRING
    key_7optSTRING
    value_7optSTRING
    key_8optSTRING
    value_8optSTRING
    key_9optSTRING
    value_9optSTRING

    Outputs (1)

    NameTypeDescription
    DICTDICT