ComfyUI Node

Random Number Gen

Reproducible randomness — a weirder phrase than it should be

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Random Number Gen
    • float_val
    • int_val
    seed0
    min_val0.00
    max_val1.00
    mode

    You want random values in your workflow - random strength, random CFG, random noise in a parameter - but you also want the exact same random values next time you run. That's the deal Random Number Gen makes: it rolls a number between a min and max, seeded, so the same seed always produces the same number. Reproducible randomness is what keeps ComfyUI workflows shareable, and this node bakes it in.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. The randomness lives entirely in the pack - no API, no system entropy needed beyond what Python's random module uses.

    How it works

    Four required inputs:

    • seed - the reproducibility key (INT, default 0)
    • min_val - the bottom of the range (FLOAT, default 0)
    • max_val - the top (FLOAT, default 1)
    • mode - dropdown: float or int

    Two outputs (both always produced, regardless of mode):

    • float_val - the result as a FLOAT
    • int_val - the result as an INT

    The implementation creates its own random.Random(seed) instance per call and draws from it - that's the reproducibility. float mode uses uniform(min, max); int mode uses randint(int(min), int(max)). One detail worth knowing: randint is inclusive of both ends, so int mode between 1 and 6 can give 1 or 6 - it's a dice roll, not a 1-to-5.

    Because the generator is created fresh from the seed every time, you don't have to worry about other random nodes in your graph interfering. Change the seed, get different values. Keep it, get the same ones.

    Where you'll use it

    • Parameter jitter. Randomize a strength or CFG within a sane band to explore variations, while keeping each run reproducible via the seed.
    • Feeding Number Compare. Roll a 0–1 value and compare it to a threshold for percentage-based branching (e.g. "30% of the time, do the detail pass").
    • Seed sweeps. Pair with Number Range for structured exploration, or just randomize and let the seed hold things together.

    Installing it

    One install for all nodes. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. The pack's requirements (numpy, torch, opencv-python) are already in stock ComfyUI; no model downloads, nothing heavy. Don't confuse it with cubiq's "ComfyUI Essentials" - a different, larger pack in maintenance mode that shows up under similar search terms.

    Gotchas

    • The two outputs aren't "mode-consistent." In int mode, float_val is still produced (as float(res) of the int). Pick one output and stick with it; don't assume float_val came from uniform() in int mode.
    • randint includes the max. If you want exclusive behavior, subtract 1 from max_val.
    • The seed field's max is 0xffffffffffffffff - you won't hit the ceiling in practice, but you can't paste a negative seed in.
    • It's a small pack with little community presence; the behavior here is plain enough that the code is the doc.
    CategoryDebugPadawan/Math

    Inputs (4)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000
    min_valFLOAT0.00
    max_valFLOAT1.00
    modeCOMBO2 options: float, int

    Outputs (2)

    NameTypeDescription
    float_valFLOAT
    int_valINT