LayerUtility: Random Generator
Random Generator — one node, three flavors of random
- image
- int
- float
- bool
Sometimes you don't want ComfyUI's built-in seed widget, you want an actual random value in your graph - a strength that wobbles a bit each run, a coin-flip that turns a branch on or off, a random index into a list. Random Generator is the "give me a number, any number" node: set a range, get back a random int, a random float, and a random boolean, all from one node instead of wiring three separate ones.
How it works
You give it min_value and max_value and it draws within that range, formatting the float side to float_decimal_places places of precision. All three outputs - int, float, bool - come off that same node in one execution, so you get all three flavors of "random" for the price of one node drop, even if a given graph only ends up using one of them.
The fix_seed toggle is the one that matters most in practice. Leave it off and the node redraws a fresh value on every queue. Flip it on and it locks to whatever it last drew, so repeat runs stay identical - handy when you've found a random value you like and want to keep it while you tweak something else in the graph.
There's also an optional image input that doesn't feed into the math at all. It's there so you can hook any upstream image into it - the classic trick custom-node authors use to force ComfyUI to treat the node as "changed" and re-run it on every generation, since a node with nothing new coming in otherwise gets cached and just returns its last cached value forever.
The inputs and outputs that matter
min_value/max_value- the range to draw from (floats, so fractional ranges are fine).float_decimal_places- how many decimals thefloatoutput is rounded to.fix_seed- off redraws every run, on freezes the last draw.
Outputs: int for anything expecting a whole number (an index, a batch count, a loop iteration), float for a strength, weight, or CFG-style slider, and bool for gating a switch node on or off.
How to install it
Part of the LayerStyle pack. Via ComfyUI Manager: search ComfyUI Layer Style, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt
Restart ComfyUI and find it under 😺dzNodes → LayerUtility → Data. No models to download for this one - it's pure Python logic.
Common issues
There's not much to break in the node itself. If the value it gives you looks suspiciously identical run after run, check fix_seed first - it's easy to leave it flipped on from a previous test. If you want it to redraw in sync with a specific generation rather than every single queue press, wire something from that generation into the optional image input rather than leaving it dangling.
The failure mode that actually bites people is the same one across this whole pack: if Random Generator (or any other LayerStyle node) is simply missing from your node menu, the pack failed to import, not this specific node. LayerStyle carries a long dependency chain - transformers crossed with a stray tensorflow install is the recurring offender - and one broken import takes every LayerStyle node down at once. This is especially common on an old install from before the pack split into LayerStyle and the heavier LayerStyle Advance companion repo. Reinstall clean, or use Manager's "Try Fix" and actually read what it failed on before assuming this node is the problem.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| min_value | FLOAT | 0.00-100000000000000–100000000000000 | — |
| max_value | FLOAT | 10.00-100000000000000–100000000000000 | — |
| float_decimal_places | INT | 11–14 | — |
| fix_seed | BOOLEAN | false | — |
| imageopt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| float | FLOAT | — |
| bool | BOOLEAN | — |