Nodes/AUN ComfyUI Nodes/Random Any Switch
ComfyUI Node

Random Any Switch

Roll the dice on any kind of data, not just text

By loz2754·Created 8 months ago·Updated a day ago· 5
Random Any Switch
  • input_1
  • input_2
  • input_3
  • input_4
  • input_5
  • output
  • selected_index
seed0

Most random switchers are picky - they only switch text, or only integers, or only models. Random Any Switch doesn't care what you plug in. It's a five-input random selector where every socket is typed * (any type), so you can randomly flip between three different prompts, or two images and a latent, or a whole mix of unrelated things, all in one node. It outputs whatever it picked plus the index of the pick.

How it works

Connect up to five candidates (input_1input_5, all optional) and hit run. The node rolls, passes the chosen input through its output output unchanged, and reports which one won via selected_index (INT). That's the whole mechanism - no coercion, no type juggling, no hidden conversions. Whatever goes in comes out; the node is just the dice.

The seed input is the part you'll actually manage. It's the random seed for the selection, so:

  • Change seed → different pick each run (assuming the seed isn't shared/fixed elsewhere).
  • Fix seed → reproducible selection, which is exactly what you want when a batch worked and you need to reproduce it.

If you want it to cycle rather than be random, this isn't the node - the AUN pack's Random/Select INT and Random Text Index Switch cover deterministic Increment mode, and AUN Any Index Switch-style nodes handle index-driven switching. Random Any Switch is deliberately the dumb, useful random picker.

Where it shines

  • A/B/C testing images - plug three preview/load branches into it, randomize, and batch through them.
  • Random model + prompt combos - since it accepts any type, you can wire a MODEL into slot 1, a CLIP into slot 2, etc., and it'll swap whole sub-graphs' worth of values... as long as what you're switching actually makes sense to swap (the downstream node has to accept whatever wins).
  • Wildcard-style variation - randomize anything in a workflow without building a big conditional structure.

The honest caveats

Because the output is * (any type), ComfyUI's type checking can't save you - if you randomize between a MODEL and a STRING and feed the output to a node expecting MODEL, it'll fail on the run where STRING wins. Design the slot contents to be type-consistent with what's downstream, or the "any" freedom becomes a foot-gun. Also, no label output here - if you need to know which candidate won as text, grab selected_index and map it elsewhere.

Install

Part of AUN ComfyUI Nodes (loz2754):

cd ComfyUI/custom_nodes
git clone https://github.com/loz2754/AUN-ComfyUI-Nodes

or ComfyUI Manager → "AUN ComfyUI Nodes" → install → restart. Pack deps (piexif, opencv-python-headless, imageio-ffmpeg, requests) install via Manager; no models, no keys.

If you only ever randomize text, AUN Random Text Index Switch is the more ergonomic cousin (it bundles up to 20 text inputs with mode selection in one node). But the moment your randomization needs to span data types, Random Any Switch is the one that fits.

CategoryAUN Nodes/Utility

Inputs (6)

NameTypeDefaultDescription
seedINT00–18446744073709550000Seed for the random selection. Changing this will change the choice.
input_1opt*Optional candidate #1 (any type).
input_2opt*Optional candidate #2 (any type).
input_3opt*Optional candidate #3 (any type).
input_4opt*Optional candidate #4 (any type).
input_5opt*Optional candidate #5 (any type).

Outputs (2)

NameTypeDescription
output*
selected_indexINT