Nodes/petty-paint-comfyui-node/PPSelectRandomValue
ComfyUI Node

PPSelectRandomValue

Pick a random item from a list and wire it anywhere

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
PPSelectRandomValue
  • value_list
  • random_value

You have a handful of prompt variants, LoRA names, or checkpoint choices, and you want the graph to roll one at random each run. PPSelectRandomValue is the tiny utility that does it: a list goes in, one random element comes out, and because the output is typed as ANY it plugs into nearly anything - a prompt string, a model name, an index, a conditioning pulled out of a batch. It's the "surprise me" node, and for such a simple thing it quietly unlocks a lot of variation in your workflows.

How it works

One input - value_list, typed LIST with a default of an empty list - and the node calls random.choice(value_list) on it. The output, random_value, is typed ANY because the list could hold strings, numbers, or anything else; the node doesn't care what it's picking, it just picks. Two edge cases worth knowing:

  • If the list is empty, it returns None rather than crashing. Whether that's graceful or a silent foot-gun depends on what you feed it into.
  • There's no IS_CHANGED override, which means ComfyUI treats the node as unchanged unless an input changes. In practice that usually still means a fresh pick each queue when the input list is itself fresh - but if you want to guarantee a re-roll every execution, you'll want to make sure the list upstream isn't being cached.

Where it shines

The classic use is randomizing prompts: build a list of prompt strings (from a PettyPaintTexts_to_Conditioning batch, a JSON array, or any list node), pick one at random, and feed it to a text encoder. Same pattern works for randomly choosing a checkpoint or LoRA name from a list so a batch run explores more of your model library. It's also handy for picking one conditioning out of a list to feed a sampler - the pack's PettyPaintTexts_to_Conditioning produces a list, and this is the natural selector.

The honest caveats

There's no seed and no weighted selection - every item is equally likely, and you can't reproduce a given pick. For the "shuffle my batch" use case that's fine; for anything where you need to re-run the exact same choice, hardcode it instead. And since the output is ANY, ComfyUI won't catch type mismatches for you - if you pick from a list of strings and feed it into an INT port, the error shows up downstream, not here.

Installing it

It ships in the petty-paint pack, so install once and it's available. ComfyUI Manager search "Petty Paint", or:

cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node

restart, and you're done. No models to download and no heavy dependencies - the pack's pinned Flask isn't even imported by the current source.

CategoryCustomNodes

Inputs (1)

NameTypeDefaultDescription
value_listLIST

Outputs (1)

NameTypeDescription
random_valueANY