Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > AUN-ComfyUI-Nodes > Random Any Switch

ComfyUI Node: Random Any Switch

Class Name

AUNRandomAnySwitch

Category
AUN Nodes/Utility
Author
loz2754 (Account age: 763days)
Extension
AUN-ComfyUI-Nodes
Latest Updated
2026-11-08
Github Stars
0.01K

How to Install AUN-ComfyUI-Nodes

Install this extension via the ComfyUI Manager by searching for AUN-ComfyUI-Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter AUN-ComfyUI-Nodes in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Random Any Switch Description

Selects a non-None input using a seed, returning its value and original input index.

Random Any Switch:

AUNRandomAnySwitch chooses one available value at random from a group of candidates, making it useful when you want variation in a workflow without manually changing which branch supplies a value. The choice is controlled by a seed, so the same available candidates and seed produce the same selection. The node can pass through different kinds of values without converting them, which makes it useful for choosing among alternatives such as prompts, images, or settings.

Random Any Switch Input Parameters:

seed

The required integer that controls the selection. Its default is 0, its minimum is 0, and its maximum is 18446744073709551615. Change the seed to get a different possible choice; keeping the same seed and the same available candidates produces the same choice, even when the node runs again. A different seed can still happen to select the same candidate.

input_1

An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 1 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.

input_2

An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 2 when reported by selected_index, regardless of whether input_1 is available. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.

input_3

An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 3 when reported by selected_index; unused earlier positions do not change that number. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.

input_4

An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 4 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.

input_5

An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 5 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.

Random Any Switch Output Parameters:

output

The value from the selected candidate, passed through without conversion by this node. It can therefore be any type accepted by the candidate inputs. If none of the five candidates has a value other than None, output is None; check this before relying on the result in a later node.

selected_index

An integer identifying which candidate supplied output. Values 1 through 5 correspond directly to input_1 through input_5, not to a renumbered list of available candidates. The value is 0 when no candidate is available, so it can also help you distinguish an empty selection from a valid one.

Random Any Switch Usage Tips:

  • Supply values only to the candidates you want considered. Each candidate whose value is not None is included in the selection, while a candidate with a None value is skipped.
  • Keep the seed unchanged when you need to reproduce a selection with the same available candidates. Change the seed when you want another possible result; changing it does not guarantee a different candidate.
  • Use selected_index when you need to know which original input position was chosen. For example, if only input_2 and input_5 are available, the reported index will be 2 or 5.
  • Check that at least one candidate supplies a value before sending output to a downstream node that requires one. If no candidate is available, the node returns None and index 0.

Random Any Switch Common Errors and Solutions:

No candidate selected: output is None and selected_index is 0

  • Explanation: This is the node’s defined result when all five candidate values are None; it is not an error message emitted by the node.
  • Solution: Provide a non-None value to at least one of input_1 through input_5, then check the result again.

Re-queuing produces the same selection

  • Explanation: The node is set to run again when queued, but it creates its random selection from the supplied seed each time. With the same seed and the same available candidates, the choice repeats.
  • Solution: Change the seed to request another possible selection. Remember that two different seeds can still choose the same candidate.

A connected candidate is never selected

  • Explanation: The code excludes any candidate whose received value is None, even if a connection appears to be present.
  • Solution: Check the upstream value and make sure it is not None when this node runs.

selected_index does not match the candidate’s position in the available list

  • Explanation: The index refers to the original socket number. For example, when only input_2 and input_5 have values, the possible indices are 2 and 5, not 1 and 2.
  • Solution: Match the reported number directly to the input name, such as 5 for input_5.

A downstream node cannot use output

  • Explanation: This node passes through the selected value without converting its type. A later node may require a different type, or it may receive None if no candidate was available.
  • Solution: Check which candidates are available and whether their values suit the downstream node. Also check whether selected_index is 0 before using output.

Seed value is outside the allowed range

  • Explanation: The interface specifies a minimum seed of 0 and a maximum of 18446744073709551615. The node source does not define a custom error message for an out-of-range entry.
  • Solution: Enter an integer within the specified range, or use the default value of 0.

Random Any Switch Related Nodes

Go back to the extension to check out more related nodes.
AUN-ComfyUI-Nodes
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Random Any Switch