Random Choice (NH)
Weighted randomness for prompts, LoRAs, and branch picking
- input_0
- input_1
- input_2
- input_3
- input_4
- input_5
- result
- picked_index
- probabilities
The most annoying thing about randomness in ComfyUI is that "random" usually means "one random thing, every run, forever." Random Choice (NH) gives you the version you actually want: pick one of up to six generic inputs on every run, with weighted odds, and a seed so you can lock the sequence when you hit something you like.
You connect up to six inputs (input_0 through input_5), any type - prompts, models, LoRA names, images, whatever the wildcard * type accepts. weights is a comma-separated list like 1,1,1,1,1,1 that sets each input's odds relative to the others. Weight 3 vs 1 means that input fires three times as often. The node outputs result (the chosen value), picked_index (which original slot number won, useful for logging or feedback), and probabilities - a handy string like 16.7%, 16.7%, ... showing the effective odds.
How the weighting actually works
The weights are normalized: each weight divided by the total becomes that input's probability. Missing weights default to 1.0, so 1,3 with six inputs still gives the rest of them weight 1. Zero weights are allowed and effectively exclude an input. The pick itself uses a seeded RNG - seed plus a fresh roll each run - and here's the bit worth internalizing: seed 0 means non-deterministic. With a seed of 0 the node falls back to unseeded randomness, so you get a different pick every run. Give it a nonzero seed and the whole sequence becomes reproducible. That's the same convention ComfyUI uses for sampler seeds, and it trips people up in the opposite direction - they set seed 0 expecting fixed and get chaos.
Because it must fire fresh on every run, this node is one of those per-run nodes the KB's plumbing doc warns about: it always re-executes, and anything downstream of it does too. That's correct behavior for a random picker - you don't want ComfyUI caching the last pick - but don't be surprised if a workflow containing it never "settles" into a stable cached state.
Where it shines
The killer use is prompt variation: connect a few different style fragments to the inputs and feed result into a Prompt Template or CLIP encoder, and every run gets a different prompt - or the same one, if you lock the seed. It works just as well for choosing between two LoRA loaders or two branches, since the * type accepts models too. Weighted odds matter here: put a "safe" default at weight 4 and two experimental styles at weight 1 each, and most runs stay in the safe zone while you still get variety.
Install
Part of NH-Nodes:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
No models or heavy dependencies - it's a logic node.
Common issues
If result keeps being None, you haven't connected any inputs (or only connected slots whose weights you zeroed). If the pick "ignores" your weights, check the syntax: commas, no spaces in weird spots, 1,1,1,1,1,1 for six inputs. And the seed-zero behavior is the one that sends people to the forums: with 0 it's random every run by design. Lock a nonzero seed for reproducibility, and treat picked_index as your audit trail - it tells you exactly which slot won so you can verify the odds are doing what you think.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–4294967295 | — |
| weights | STRING | 1,1,1,1,1,1 | — |
| input_0opt | * | — | |
| input_1opt | * | — | |
| input_2opt | * | — | |
| input_3opt | * | — | |
| input_4opt | * | — | |
| input_5opt | * | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| result | * | — |
| picked_index | INT | — |
| probabilities | STRING | — |