Efficient Random Integer Generator
A random integer that lands on a clean multiple
- INT
Every diffusion model cares about round numbers. Latents get downscaled 8x by the VAE, and plenty of workflows (Flux especially) want dimensions divisible by 64, not just any integer. So if you're generating a random width, a random batch count, or any number that has to land on a "clean" value, a plain random-int node isn't quite enough - you'll get an off-grid number and either eat an error or a silent crop. That's the whole reason this node exists: it picks a random integer in a range and snaps it to the nearest multiple of a divisor you set, in one step.
How it works
You give it a min_value, a max_value, and a divisor. It draws a random integer somewhere in that range, then rounds it to the nearest multiple of the divisor, and hands that back out as a single INT. Every time the graph runs, it rolls again - the README describes it plainly as updating with each generation, so you don't need to wire up ComfyUI's separate randomize-seed convention on top of it. Point it at a width or height range with divisor set to 64 and you'll never get handed a resolution your model chokes on.
The inputs and outputs that matter
There are only three widgets, and they're all required:
- min_value (
INT, default 0) - the low end of the range. - max_value (
INT, default 100) - the high end. - divisor (
INT, default 1) - the multiple the result gets snapped to. Set this to 8 or 64 for image dimensions; leave it at 1 if you just want a plain random integer and don't care about rounding.
The single output is INT - wire it straight into a width or height field on something like Empty Latent Image, a batch-count input, or any other node expecting a whole number.
Why reach for this instead of the built-in seed widget
ComfyUI already gives every INT widget a control_after_generate dropdown (randomize / increment / decrement / fixed), and it's tempting to think that covers "random number" needs. It doesn't cover this case, though - that control lives on the widget itself, isn't wireable, and has no concept of snapping to a divisor. This node is a real graph node with a real output, so you can pipe the same random-but-valid number into several downstream nodes at once, run math on it, or reroute it - the sort of thing you can only do once a value exists on a wire rather than buried in a widget. If you're procedurally generating a batch of images at varying-but-valid resolutions, or stress-testing a workflow across a spread of sizes, this is the tool for that, not the seed dial.
Installing it
Two ways, same result:
- ComfyUI Manager: open the Manager, search "ComfyUI-Random-Int-Divisor-Node", install, restart.
- Manual:
Restart ComfyUI afterward.cd ComfyUI/custom_nodes git clone https://github.com/Jaminanim/ComfyUI-Random-Int-Divisor-Node
The README doesn't list any Python dependencies beyond what ComfyUI already ships, and there are no model files to download - it's a small, self-contained utility pack. If you don't see it after a Manager search, the manual clone is the reliable fallback for smaller, less-indexed packs like this one.
Common issues
The pack's README is intentionally minimal - it's a one-paragraph description, no troubleshooting section - so most of what can go wrong here is just arithmetic, not a bug:
- Divisor set to 0 has no meaningful "nearest multiple," so keep it at 1 or higher. If you want an unrounded random integer, a divisor of 1 is the way to get that, not 0.
- A range narrower than your divisor (say min 10, max 20, divisor 64) leaves the node with nothing valid to snap to inside your bounds - widen the range or shrink the divisor so at least one multiple actually falls between min and max.
- If the node's missing after install, it's not registered anywhere unusual - it's a fresh, small pack, so a full ComfyUI restart (not just a browser refresh) after cloning is what actually loads it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| min_value | INT | 0 | — |
| max_value | INT | 100 | — |
| divisor | INT | 1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |