π² Random Int in Range
Random Int in Range β ComfyUI Node Guide
- random_int
The integer version of this pack's Random Float in Range, and functionally the same idea ComfyUI already applies to a KSampler's seed widget - pick Randomize and you get a new number every run - generalized so it works on any integer input in your graph, not just a seed field.
Inputs: min_value and max_value set an inclusive range, both with effectively unbounded span in either direction. seed is optional and follows the same convention as everywhere else in this pack: -1 (default) gives a genuinely fresh number every run, any other fixed value makes the result reproducible.
Output: a single random_int.
Where this earns its keep over just eyeballing a number by hand: randomizing a batch count, a step count, which line of a numbered wildcard list gets picked, or feeding a value into something like this pack's Load Random Checkpoint node's repeat_count. Anywhere you'd otherwise be manually varying an integer between runs to see what happens, wire this in instead and let it vary for you - set a fixed seed once you land on a range that's producing good results and it locks in place.
It's worth being deliberate about the range you set rather than just grabbing wide defaults. If you're randomizing step count for a speed/quality comparison, a range like min_value=15 to max_value=40 gives you a meaningful spread without wasting a run at a step count so low the image falls apart. If you're randomizing which of ten wildcard lines gets used elsewhere in your graph, match max_value to the actual line count - set it too high and you'll just get out-of-range indices that some downstream node has to clamp or ignore, quietly wasting part of your intended range. It's the same integer-versus-float distinction as this pack's Random Float in Range node: reach for this one whenever the thing you're varying is inherently a whole number - a count, an index, a line number - rather than something that can meaningfully land between two values.
Installing it: ComfyUI Manager, search "ComfyUI-mnemic-nodes," or the manual route: cd ComfyUI/custom_nodes && git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes, then restart. No dependencies beyond Python's own standard library - this is as low-risk an install as any node in the pack gets.
Like its float sibling, there isn't much that can actually go wrong here. The one real gotcha, and it's the same one that shows up across every randomizer node in this pack: the node itself doesn't decide when to reroll, ComfyUI's queue does. Leave Control After Generate on its default (Fixed) and you'll get the exact same "random" number every single run, which looks like the node silently failing when it's actually behaving exactly as configured - set it to Increment or Randomize if you want a genuinely new value each time you hit queue.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| min_value | INT | 0-18446744073709550000β18446744073709550000 | Minimum value for the random integer (inclusive). |
| max_value | INT | 100-18446744073709550000β18446744073709550000 | Maximum value for the random integer (inclusive). |
| seedopt | INT | -1-1β18446744073709550000 | Seed for random number generator. Use -1 for random seed (different each time), or set a specific value for reproducibility. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| random_int | INT | β |