ComfyUI Node

RandomIntRange

A reproducible random integer, on purpose

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
RandomIntRange
    • INT
    min0
    max100
    seed0

    This is the node you reach for when you want a random number in a range but you still want to be able to reproduce a run. UC_RandIntRange ("RandomIntRange") picks a random integer between min and max, and the trick is that it's deterministic: same seed, same number, every time, across restarts. That's what separates it from the sea of "random" utility nodes that pull from global RNG state and can't be pinned down.

    What it actually does

    Three inputs, one output. min (default 0) and max (default 100) define the range, and seed (default 0) drives a Python random.Random(seed) instance - the node calls randint(min, max) on that seeded generator. No hidden global state, no GPU entropy. The seed widget carries the control_after_generate dropdown, so you get the full fixed/increment/randomize behavior: leave it fixed to keep the same number (reproducibility), or set it to randomize to roll a fresh one every run.

    The output is a single INT socket. Feed it into any converted-to-input widget - a LoRA weight, denoise strength, CFG, a width/height, a prompt slot, a mask-blur radius. Because the value is reproducible from the seed, you can lock a "lucky" combination by copying the seed out of the workflow, exactly like you'd pin a KSampler seed.

    Where it earns its keep

    Two patterns. First, sweeps: wire the seed to randomize, run a few dozen generations, find the combo you like, then flip to fixed and save. Second, grids: same seed, same number - so you can drive several nodes from one seed and have the whole workflow move in lockstep. Keep min strictly below max; an inverted range will behave oddly and there's no guard rail to catch it.

    Setup

    It's part of the ComfyUI-UtilsCollection pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
    

    Restart, or install via ComfyUI Manager by searching "UtilsCollection". The pack's only real dependencies are opencv-python and typing-extensions, which Manager handles for you.

    Gotchas worth knowing

    Same seed-timing trap as every seed-ish node in ComfyUI: with the widget on randomize, the number shown after a run is the one for the next run. If you see a nice result and want to reproduce it, the value in the box may already have moved on - drag the output image back into ComfyUI to recover the workflow (and seed) from the PNG metadata. And one pack-level note: UtilsCollection re-registers some primitive/logic node IDs that other packs provide; when ComfyUI asks whether to replace a node on workflow load, that's this pack's migration doing its thing, and accepting is usually right.

    Categoryutils/primitive

    Inputs (3)

    NameTypeDefaultDescription
    minINT0-9223372036854776000–9223372036854776000
    maxINT100-9223372036854776000–9223372036854776000
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    INTINT