ComfyUI Node

Random Boolean

Coin flip with a +n bonus for your automation

By LaVie024·Created about a year ago·Updated 8 months ago· 8
Random Boolean
    • BOOLEAN
    • INT+n
    seed0
    n0

    RandomBoolean is exactly what the name says: every run it hands you a True or a False, seeded so you can reproduce it. The reason it's worth having over just reaching for the nearest seed control is the second output - the same result cast to an int with an offset n you choose. One flip, two consumable outputs, no extra nodes.

    Why you'd reach for it

    Random branches are how you add variety to a workflow that's otherwise deterministic. Feed the boolean into a BooleanSwitch and every run picks one of two prompt styles, one of two models, one of two denoise paths. It's the difference between "generate 20 images, all the same layout" and "generate 20 images, each one coin-flipping between two looks." The seed input matters here: set it and the flip is reproducible - run the queue twice and you get the same branch - which is invaluable when you're debugging why a batch looks the way it does.

    How it works

    Under the hood it's a single random.choice([True, False]) seeded from the seed input, then bool() on the result. The int output is the clever bit: int(True) + n is 1 + n, int(False) + n is 0 + n. So with n = 0 you get a binary 0/1 signal that plugs straight into anything expecting an int, and with n set to something like 5 you get a random pick between two values - 5 or 6. It's a two-in-one node masquerading as a one-in-one.

    The inputs and outputs

    • seed (INT, default 0) - controls reproducibility. Same seed, same flip.
    • n (INT, default 0) - the offset added to the integer output. The whole "int+n" trick lives here.
    • BOOLEAN - the raw True/False. Wire this into switches and conditionals.
    • INT+n - int(result) + n. Wire this into anything taking an integer.

    That's the complete interface. Two inputs, two outputs, no hidden options.

    Installing it

    It's part of comfyui-lopi999-nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/LaVie024/comfyui-lopi999-nodes
    

    Restart ComfyUI after cloning, or use ComfyUI Manager and search "comfyui-lopi999-nodes." No models, no dependencies beyond the pack itself.

    Common issues

    Two small things trip people up. First, the seed is the flip determinant - if you randomize the seed every run (the usual "control after generate" behavior in the scheduler), you get real randomness; if the seed is fixed, the branch is fixed too, which is the point but also a classic "why is it always the same side" moment. Second, n only shapes the int output; the boolean is always a clean coin flip regardless. If you're getting 1 and 0 when you expected True/False, check that you're reading the INT+n wire, not the boolean one.

    Categorylopi999/random

    Inputs (2)

    NameTypeDefaultDescription
    seedINT00–9223372036854776000
    nINT0-9223372036854776000–9223372036854776000

    Outputs (2)

    NameTypeDescription
    BOOLEANBOOLEAN
    INT+nINT