APNext Random Integer Generator
A random integer in a range, for seeds and wildcard logic
- INT
RandomIntegerNode (APNext Random Integer Generator) does exactly what it says: spits out a random whole number between a minimum and a maximum. That's the entire node. It's a tiny utility, but a genuinely useful one - anywhere a ComfyUI graph takes an integer, this can feed it a fresh random value each run, which is the backbone of a lot of "make every generation different" tricks.
How it works
Two inputs, one output:
min_value(default 0) andmax_value(default 10) - the inclusive range to draw from. Both accept a wide span (roughly ±1 billion), so you can use it for anything from picking 0-4 to generating a full random seed.- Output: a single
INT.
Wire that INT into any integer input in your graph. The obvious ones:
- A sampler's
seed- drive it from here for random seeds under your own control. - An index or count - a
batch_size, a "pick option N" selector, a step count you want to vary. - Another dagthomas prompt node's
seed- feed random category rolls a random seed so the variety compounds.
The one thing to understand about ComfyUI and "random"
ComfyUI caches node outputs and only re-runs a node when something about it changes. A node that returns a constant will happily return the same value every queue because nothing upstream changed. Random-value nodes get around this so they re-roll each run - which is what you want when you're batching for variety. The flip side: if you're chasing reproducibility, a value that changes every run is the opposite of what you need. Note the number it produced (or use a fixed seed elsewhere) when you want to lock a result.
Installing it
ComfyUI Manager: search comfyui_dagthomas, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas
pip install -r requirements.txt
No key, no downloads - it's a few lines of Python. Works even if the pack's LLM nodes can't reach anything.
Common issues
It re-rolls when I wanted it fixed. That's by design for a random node. If you need a stable integer, use a fixed value node (or a primitive set to fixed) instead - this one exists precisely to vary.
min > max. Set min_value above max_value and you've defined an empty range; expect an error or a nonsense result. Keep min ≤ max.
Downstream node ignores it. Make sure the target input is actually an integer type and is wired to this output, not left on its own widget value - a connected input overrides the widget, but only if it's truly connected.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| min_value | INT | 0-1000000000–1000000000 | — |
| max_value | INT | 10-1000000000–1000000000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |