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

create DICT from FLOATs

Float values in a dict, guaranteed — for the config that does math

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

    "create DICT from FLOATs" builds a dictionary where every value is coerced through Python's float(). It's the typed sibling of create DICT for when your dict is really a numeric settings blob - CFG scales, denoise strengths, weights - and you don't want to find out later that one of the values rode through as a string and broke a downstream comparison.

    ComfyUI is loose with numbers: an INT can plug into a FLOAT port and vice versa, and text widgets will happily hold "0.8". That looseness is great until it isn't. If something downstream does if cfg["denoise"] < 0.3, you want 0.8, not "0.8" (which would raise a TypeError in Python). This node closes that door by casting every value at build time.

    How it works

    Same dynamic-input machinery as the rest of the family: start with key_0 (STRING) + value_0 (FLOAT), add more key_N/value_N pairs as needed, and the node folds every connected pair into a dict with float() applied to the value. Only fully connected pairs make it in - a key without its value is ignored rather than erroring.

    Note the stale docstring again: it claims the node "creates a new empty dictionary." That's a copy-paste from the generic class; the actual behavior is the key→float dict described here, and the source confirms the cast. Trust the mechanism, not the label.

    Inputs and outputs

    • key_0 (STRING) - the entry name.
    • value_0 (FLOAT) - the numeric value. The input you'll actually touch.
    • Output: DICT - a dict whose values are all float.

    When you'd reach for it

    Numeric config bundles are the sweet spot: gather a scale, a strength, and a threshold into one dict, hand it to a node that reads settings back, and know every value will behave like a number. It also pairs naturally with the pack's FLOAT arithmetic nodes - do a bit of math, stash the results in a dict, and let a get pull them out elsewhere.

    A practical note on float(): wiring an INT port in gives you 8.0 rather than 8. Usually fine; occasionally surprising if something downstream checks for integer equality. If that matters, use the INT variant instead. And if you only need one or two floats, a plain create DICT is less ceremony - the typed version earns its keep when the dict is mostly numbers and correctness beats convenience.

    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.

    CategoryBasic/DICT

    Inputs (2)

    NameTypeDefaultDescription
    key_0optSTRING
    value_0optFLOAT

    Outputs (1)

    NameTypeDescription
    DICTDICT