ComfyUI Node

⬖ Boolean To Int

Turn a yes/no into a number your graph can use

By alt-key-project·Created 3 years ago·Updated 2 years ago· 114
⬖ Boolean To Int
    • result
    booleanfalse
    on_true1
    on_false0

    Booleans are everywhere in a ComfyUI graph once you start gating things - "is this the first frame", "did this comparison pass", "should I use path A or B". But most nodes don't take booleans; they take numbers. Boolean To Int [Dream] is the tiny adapter that solves that: feed it a boolean, it outputs the integer you say it should - on_true if the boolean is true, on_false otherwise. Nothing more, nothing less.

    How it works

    It's a two-way switch with a boolean as the selector. on_true defaults to 1, on_false defaults to 0, but both are fully editable - so you can map "true" to 300 and "false" to 0 if that's what your graph needs. The single output, result, is an INT.

    The inputs

    • boolean - the condition. Wire in a comparison result, a checkbox, or anything else that produces a boolean.
    • on_true - INT, default 1. Output when the boolean is true.
    • on_false - INT, default 0. Output when false.

    That's all three inputs, and there are no hidden ones.

    Where it fits

    The pack's Big X Switch nodes use an INT select input to choose between up to ten inputs - and that select is exactly the kind of thing a boolean-to-int conversion feeds nicely when you're choosing between two fixed paths. It's also handy for turning a per-frame condition into a value: drive the boolean from a frame counter comparison and the animation can switch behavior at a specific frame. It's not exciting, but when you're mid-workflow and realize a comparison outputs a boolean where you need a number, this is the missing piece you'll be glad exists.

    Installing it

    Ships with Dream Project Animation Nodes - ComfyUI Manager (search Dream Project Animation) or clone https://github.com/alt-key-project/comfyui-dream-project into custom_nodes, pip install -r requirements.txt, restart. No model downloads.

    Common issues

    The one foot-gun is thinking the node generates the boolean - it doesn't; something upstream has to produce it. And if you leave the defaults and wire it somewhere expecting the "true" value to be 1, that's what you'll get, so don't get fancy with the mapping unless you have a reason. There's also a Boolean To Float sibling in the same pack if your downstream input needs a float instead. That's genuinely the whole failure surface.

    Category✨ Dream/🛠 utils/⭆ switches

    Inputs (3)

    NameTypeDefaultDescription
    booleanBOOLEANfalse
    on_trueINT1
    on_falseINT0

    Outputs (1)

    NameTypeDescription
    resultINT