Random Number
Random Number for reproducible seed farming
- int
- float
The KSampler's own seed field already has a randomize dropdown, so you might be forgiven for wondering why a Random Number node exists at all. The answer is that the dropdown only rolls a seed - and it rolls it silently after each run, which is how beginners lose the good seed. This node is the version with a steering wheel: it draws from a range you choose, hands you the result, and replays the same draw whenever you ask. Set min to 0, max to 9999999, wire the int output into a KSampler seed, and you've got a seed farm you can actually pin down and re-run.
It's one node, three inputs, and the entire pack weighs about as much as a comment. There are no model files, no dependencies, no torch extensions - just Python's standard random module. The category is Logic/Math, so double-click the canvas and search "Random Number" or right-click → Logic → Math to drop it in.
How it works
The source is short enough to read end to end. If min_value is bigger than max_value it swaps them so you never get an inverted range error. Then it calls random.seed(seed), draws a float with random.uniform(min, max), and truncates that float to an int with int(). Both values come out of the same draw, so the int and float outputs are always consistent - the int is literally the float with its decimals chopped off.
That truncation is the one real trap. int(0.9) is 0, not 1, and it rounds toward zero, so a narrow range like 0.5–1.5 will hand you ints of 0 or 1 no matter how many times you rerun. Use wide ranges for integer work and treat the float output as the honest one for continuous sliders.
The inputs and outputs that matter
- min_value / max_value (FLOAT, defaults 0 and 100): the inclusive bounds. You can type decimals - handy for denoise between 0.4 and 0.8 or CFG between 5 and 12.
- seed (INT, default 0): the reproducibility knob. Same seed, same numbers, always.
Outputs: int (INT) and float (FLOAT). Right-click the KSampler seed widget and Convert widget to input, then wire int into it; float plugs straight into Denoise, CFG, or any other FLOAT socket.
Installing it
Easiest via ComfyUI Manager: search "Random Number", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/warfy5/ComfyUI-RandomNumbers
Then restart ComfyUI. Nothing else - no pip install, no model downloads. The README's troubleshooting says to check for a folder named ComfyUI-RandomNumber (singular), but the repo is -RandomNumbers; either name works as long as ComfyUI picks up the __init__.py inside.
The gotchas worth knowing
Two things the README doesn't tell you. First, this node is not automatic: it has no IS_CHANGED hook, so ComfyUI caches its output and re-running a workflow with unchanged inputs returns the same number. That's exactly what you want for reproducibility, but if you were hoping for a fresh draw every run, you must change the seed widget yourself - this is not the KSampler's silent auto-roll. Second, the node reseeds Python's global random module on every call. It's harmless in practice, but if another node in the graph relies on random's state, this one will yank its rug.
Treat it as what it is: a bounded, replayable dice roll. For "random everything, every run," you want the KSampler's own randomize instead.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| min_value | FLOAT | 0.00-999999–999999 | — |
| max_value | FLOAT | 100.00-999999–999999 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| float | FLOAT | — |