Nodes/ComfyMath/BoolToInt
ComfyUI Node

BoolToInt

Turn a true/false into a 1 or 0

By evanspearman·Created 3 years ago·Updated about a year ago· 192
BoolToInt
    • INT
    afalse

    BoolToInt converts a BOOLEAN into an INT - true becomes 1, false becomes 0. That's the whole node. It looks trivial because it is, but it solves a real problem: a lot of ComfyUI nodes don't expose a proper boolean toggle, they expose an integer or a float that you're meant to treat as a switch (multiply something by 0 or 1 to turn it off or on, for instance). If the logic deciding true or false lives upstream - say, out of ComfyMath's own BoolBinaryOperation or FloatBinaryCondition - you need something to turn that boolean decision into a number before it can drive one of those integer-as-switch inputs.

    How it works

    a (BOOLEAN, default false) in, INT out. No configuration, no options - a checked box becomes 1, an unchecked one becomes 0.

    The inputs and outputs that matter

    • a - the boolean you're converting; toggle it directly or wire in the output of another logic node.
    • Output - a plain INT (0 or 1), usable anywhere an integer socket is expected, including as a multiplier to gate another value on or off.

    Installing it

    Search ComfyMath in ComfyUI Manager, or manually:

    cd ComfyUI/custom_nodes && git clone https://github.com/evanspearman/ComfyMath
    

    then restart ComfyUI. Pure Python, no dependencies beyond ComfyUI's own, no models - this node and the rest of the pack are available immediately after restart.

    Common issues

    There's genuinely very little to go wrong with a node this small, so the real thing worth knowing is where it fits. If you're deciding between a condition and an action - for instance computing a boolean with BoolBinaryOperation or FloatBinaryCondition and then wanting that decision to actually change a numeric value downstream rather than just gate execution - this is the bridge. If instead you want to skip or run whole branches of a graph based on a condition, look at a dedicated switch/gate node (rgthree-comfy's Any Switch is a common one) rather than trying to build branching logic entirely out of ComfyMath's arithmetic nodes; ComfyMath gives you the numbers, not the routing.

    Like the rest of ComfyMath, this pack has had no active maintainer since roughly early 2024 by community reports (a user asking for a feature addition was told the author had stepped away from the project), but it's simple enough - no external calls, no model weight dependency - that this hasn't translated into real breakage. If you do hit an issue, it's far more likely to be a wiring mistake in your own graph (plugging this into a socket that doesn't actually want a plain 0/1 integer) than a bug in the node itself.

    Categorymath/conversion

    Inputs (1)

    NameTypeDefaultDescription
    aBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    INTINT