Nodes/ComfyUI-GU_Nodepack/GU Switch Any by Index
ComfyUI Node

GU Switch Any by Index

A multi-way switch that routes anything by number — GU Switch Any by Index

By alexguryev·Created 4 months ago·Updated 23 days ago· 2
GU Switch Any by Index
    • *
    inputs2
    index1

    You want to keep three different checkpoints, two prompt sources, and a latent in one workflow and flip between them without rewiring anything. That's the job of a switch node, and GU Switch Any by Index is the GU_Nodepack take on it: up to ten inputs, any data type, and one integer that decides which input gets forwarded. Set the index, the output hands you whichever input you pointed at, and the output type matches whatever you connected.

    This is the classic A/B-switch shape from the plumbing layer - a manual routing valve, not the auto-picking "first non-empty" kind. The community has a love/hate relationship with type-erasing convenience nodes ("Please Stop using the Anything Anywhere extension" was a whole +96 post about debugging nightmares), but this one is comparatively tame: the sockets are wildcard *, the node genuinely doesn't care whether you're routing an image, a model, or a string, and it doesn't hide any wires. You can see exactly what's connected. The index is just a smarter way to pick than a boolean.

    How it works

    Set inputs to how many inputs you want (2 to 10), then hit the Update inputs button that appears on the node - that button is what actually creates the sockets via a bit of front-end JS. Change the count and forget the button and nothing changes on the canvas, which is the most common "it's broken" moment with this node. Then index (1-based, starts at 1) chooses which input passes through.

    One nicety the author built in: if index is out of range, it doesn't error - it clamps to the nearest valid input. Index 0 or index 99 just silently forwards the boundary input. The source is literally a clamp and a dictionary lookup.

    The inputs that matter

    • inputs - how many sockets to create, then press Update inputs.
    • index - which of them to forward. 1-based, so the first input is index 1, not 0.

    The single * output accepts anything and forwards it untouched. Wire it into a converted widget input downstream (right-click the widget → convert to input) and the switch becomes your A/B/C/D selector for that parameter.

    Installing it

    It ships in GU_Nodepack, so:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexguryev/ComfyUI-GU_Nodepack
    

    Restart, or install via ComfyUI Manager → search "GU_Nodepack". The pack pulls in psutil, requests, and gu-funclib via pip; nothing else, no model downloads.

    Gotchas

    The Update inputs step is the trap - changing the count does nothing until you click it. Also note the author's warning in both the node description and README: on older ComfyUI versions spurious extra inputs named any_-1 and any_0 may appear. Don't use them; they're artifacts of an old frontend bug. If you see them, ignore them or update ComfyUI. And remember it's 1-based indexing while most of ComfyUI's list-style nodes are 0-based - that mismatch has produced more than one "why is it switching to the wrong input" bug. The pack is tested on Windows and aimed at single-user installs; Linux/macOS is best-effort.

    CategoryGU_Nodepack

    Inputs (2)

    NameTypeDefaultDescription
    inputsINT22–101...10
    indexINT11–10if index is out of range 1...inputs, then use the nearest correct value

    Outputs (1)

    NameTypeDescription
    **