Nodes/Basic data handling/create DICT from STRINGs
ComfyUI Node

create DICT from STRINGs

All-string dicts, cleanly typed — when every value is text

By StableLlama·Created about a year ago·Updated 4 days ago· 48
create DICT from STRINGs
    • DICT
    key_0
    value_0

    "create DICT from STRINGs" builds a dictionary where every value is coerced through Python's str(). It's the string-specialist of the type-specific create family, and honestly the least dramatic of the four - strings are already the most forgiving type in ComfyUI. But that's exactly why it exists: when a dict is going to hold text (captions, prompts, filenames, tags), you want every value guaranteed to be a string, not a number that only looks like text.

    The subtle trap it guards against: ComfyUI's any-type coercion means a numeric port can flow into a string slot, and somewhere downstream you'll do "cfg=" + cfg["scale"] and get a TypeError from concatenating a string with a float. This node casts everything to str() at build time so the whole dict is uniformly text.

    How it works

    Same dynamic-input pattern as its siblings: start with key_0 (STRING) and value_0 (STRING), add more key_N/value_N pairs as needed, and each connected pair becomes key → str(value). Disconnected pairs are skipped. The docstring claims it "creates a new empty dictionary" - that's the stale generic description; the source confirms the str() cast and key→value behavior.

    Inputs and outputs

    • key_0 (STRING) - the entry name.
    • value_0 (STRING) - the text value.
    • Output: DICT - a dict whose values are all strings.

    When you'd reach for it

    • Building a metadata dict of captions, tags, or filenames to pass to a save or format node.
    • Normalizing mixed sources: wire a numeric port in and get "8" out, so the dict is uniformly textable.
    • Any dict destined for text interpolation or an API payload that expects strings.

    One honest caveat: str() on a float gives you "0.8", on an int "8" - readable, but if a downstream node needs the number, a string won't do. For numeric dicts use the INT or FLOAT variants instead; this one is for dicts that are text through and through. If you only need one or two string values, the generic create DICT is fine - the typed version earns its keep when the whole dict should be text.

    Install

    Part of 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.

    CategoryBasic/DICT

    Inputs (2)

    NameTypeDefaultDescription
    key_0optSTRING
    value_0optSTRING

    Outputs (1)

    NameTypeDescription
    DICTDICT