ComfyUI Node

FERandomBool

A coin flip you can actually seed

By fexli·Created 3 years ago·Updated about a year ago· 3
FERandomBool
    • bool
    true_prob0.50
    seed0

    Randomness is the soul of image generation, but sometimes you want randomness that's controllable: "this run, 70% of the time do A, otherwise do B - and let me reproduce a given outcome by pinning a seed." That's the whole job of FERandomBool. It flips a weighted coin and hands you a boolean. Nothing more, and honestly nothing less is needed.

    It lives in the fexli/utils menu and slots into the same family as the pack's other random helpers - random colors, random prompts, random LoRA selection. If you're building a "surprise me" workflow that randomizes prompts, checkpoints, or post-processing on every run, this is the decision node at the top of it all.

    Inputs and output

    • true_prob - the probability of true, a float from 0.0 to 1.0, default 0.5. Set 0.9 and the node returns true nine times out of ten.
    • seed - the reproducibility dial. The same seed and true_prob always produce the same flip, every single time.

    Output: bool, a BOOLEAN. Wire it into anything that takes a boolean - an FEOperatorIf condition, an input marked as force-input, a FEInterruptCondition if you want a random chance of bailing out.

    The details that matter

    Two things make this node better than rigging your own randomness:

    First, it's an always-change node (IS_CHANGED returns NaN), so ComfyUI doesn't cache its output between queue runs. This is the trap with naive random nodes - you set a seed, run once, and every subsequent run gives the same "random" result because the node's cached. FERandomBool re-rolls every execution, which is what you actually want when the point is variety. If you do want a stable flip across runs, just pin the seed.

    Second, the seed path is clean: it seeds an internal Random instance with your seed and compares random() < true_prob. Deterministic given the same seed - no interference from other random calls in your process.

    Where to use it

    The classic pattern: pair it with FEOperatorIf to swap between two prompts, two denoise strengths, or two output paths on a coin flip. Or gate a FERandomLoraSelect so a workflow only applies style LoRAs sometimes. It's a utility, so there's no "right" workflow - it's the node you reach for whenever a graph needs a decision that's partly luck and partly on purpose.

    Install

    Part of fexli-util-node-comfyui:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fexli/fexli-util-node-comfyui
    cd fexli-util-node-comfyui
    pip install -r requirements.txt
    

    Or via ComfyUI Manager (search fexli-util-node-comfyui), then restart. Light dependencies, no model files, no config.yaml.

    If you've ever wished a workflow would just sometimes do the interesting thing, this is the node that makes "sometimes" a seedable number.

    Categoryfexli/utils

    Inputs (2)

    NameTypeDefaultDescription
    true_probFLOAT0.500–1
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    boolBOOLEAN