pop random
Pull a random item out of a list, reproducibly
- list
- list
- item
Sometimes you don't care which item you grab - you just want a random one gone from the list and in your hand. That's DataListPopRandom. Feed it a list, and it returns two things: the list with one random element removed, and that element itself. If your list has a bunch of candidate prompts, images, or seeds and you want to pick one at random without sacrificing the rest, this is the node.
The inputs are list and an optional seed (defaults to 0). The seed is where this node earns its keep: with a fixed seed, the same list produces the same "random" pick every run. That's huge for reproducibility - you can debug a workflow, tweak something upstream, and trust that the random selection isn't silently shifting underneath you. Want a different pick each run? The seed widget has a "control after generate" toggle, so you can let it randomize per run the same way KSampler seeds work.
How it works
Mechanically it copies the list, picks an index with Python's random module, removes that item, and returns the leftover list plus the removed element. A couple of details worth knowing:
- It uses a local random generator seeded from your seed value, so it doesn't stomp on ComfyUI's global RNG state the way some random nodes do.
- If the list is empty, you get
Nonefor the item and the empty list back - no crash. - It's a cousin of
DataListPop(which pops by index) andDataListShuffle(which randomizes the whole order). If you want the full randomized order, use shuffle; if you want one random item and the rest of the list, this is the one.
Where it fits
The classic pattern is "deal one from a batch": build a list of options, pop a random one for the current run, and keep the remainder flowing into another branch for later. It also works as a lightweight random selector when you want the rest of the list for bookkeeping - the dual outputs make that natural.
Installing it
This is part of StableLlama's Basic data handling pack, a pure-Python collection with zero dependencies and no model downloads. Install once, get all 250+ nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI, or search "Basic data handling" in ComfyUI Manager and install from there. No requirements.txt conflicts because there's nothing third-party in the pack.
Common issues
The usual data-type trap applies: this wants a native data list, not a single LIST variable - convert first if your upstream outputs LIST. And remember that a fixed seed means a fixed pick: if you set seed to a constant and the "same result every time" behavior surprises you, that's the seed working exactly as designed. Leave it disconnected or toggle "control after generate" for variation.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | * | — | |
| seedopt | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| list | * | — |
| item | * | — |