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

create DICT from BOOLEANs

Build a dict where you know the values are real booleans

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

    "create DICT from BOOLEANs" is the same idea as create DICT, with one guarantee: every value in the resulting dict is a genuine Python boolean - True or False - not a string that happens to look like one. That matters more than it sounds. If you're building a settings dict that a downstream node or script checks with if cfg["use_alpha"], you want a real boolean, not "False", which is truthy and would silently do the opposite of what you meant.

    This is one of four typed builders in the pack (the others are the INT, FLOAT, and STRING versions), all sharing the same skeleton. Where create DICT accepts anything for its value slot, this one locks the value type to BOOLEAN and coerces whatever arrives with Python's bool() - so wiring a string port into it gives you a real boolean at the end.

    How it works

    Like the generic node, it starts with key_0 (STRING) and value_0 (BOOLEAN), and the dynamic-input system lets you add more pairs - key_1/value_1 and onward - each with its own string key and boolean value. On run, every connected pair is folded into a dict with the value cast through bool(). Only fully connected pairs are included; a key with no matching value is just skipped.

    One quirk worth knowing: the node's own description still reads "Creates a new empty dictionary" - that's a leftover docstring copied from the generic class. The node actually builds a key→boolean dict, and the source shows the bool() cast plainly. Don't let the stale description confuse you.

    Inputs and outputs

    • key_0 (STRING) - the entry name.
    • value_0 (BOOLEAN) - the flag. This is the input you'll actually set.
    • Output: DICT - a dict whose values are all True/False.

    When you'd reach for it

    Any time your workflow tracks switches - "apply the refiner", "save a mask", "skip this branch" - and you want to hand those flags around as one bundle. A dict of booleans is a clean way to pass a set of toggles to a control-flow or config node and keep them together instead of running five separate wires. It's also the honest answer to "why not just use create DICT?": the generic node will happily store whatever it gets, and ComfyUI's any-type coercion means a text widget can sneak a string in. If you need the value to be boolean, use the typed node and stop thinking about it.

    Install

    Part of Basic data handling - no dependencies, no models to download. Either install through ComfyUI Manager (search "Basic data handling"), or:

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

    then restart ComfyUI.

    Honest take: if your dict is all booleans, this is the right node, but don't force it. Mixed-content dicts are fine in the generic create DICT - use that for one-off config blobs and reach for this when the type actually needs to survive the trip.

    CategoryBasic/DICT

    Inputs (2)

    NameTypeDefaultDescription
    key_0optSTRING
    value_0optBOOLEAN

    Outputs (1)

    NameTypeDescription
    DICTDICT