Nodes/ComfyUI-IterSwitch/Iter_CLIPSwitch
ComfyUI Node

Iter_CLIPSwitch

The niche but honest way to make your text encoder a variable

By younger15·Created 5 months ago·Updated 5 months ago· 0
Iter_CLIPSwitch
    • CLIP
    output_index0
    input_count2
    use_last_inputtrue

    Let's be straight about this one up front: Iter_CLIPSwitch is the niche-iest node in ComfyUI-IterSwitch. Most of the time your CLIP - the text encoder that turns your prompt into conditioning vectors - rides along inside your checkpoint, so you rarely need to swap it in isolation. But the moment you do want to vary it, this node is the clean way. It's a typed switch that picks between several CLIP inputs by index, and it's honest about exactly one job.

    What it does

    Wire up to 64 CLIP inputs and the node passes one through to your CLIPTextEncode. The realistic use cases are narrow but real: comparing text encoders for the same model, or A/B testing different CLIP setups - say a different SDXL CLIP pair, or the CLIP side of a dual-encoder model - without rebuilding the graph between runs. If you're iterating on which encoder your prompt should go through, an index-controlled switch beats hand-rewiring every time.

    The reason you'd rather reach for this than a generic router is type safety. Anything-anywhere style nodes that carry every type down one wire are convenient and a known source of "why is my graph doing this" debugging pain. This switch only ever carries CLIP, its sockets are visible, and the graph stays readable.

    How it works

    Same family mechanism as the pack's other switches: output_index, input_count, and use_last_input. input_count is hooked to a web extension that physically grows or trims the node's clip_0, clip_1, … sockets as you change it - raise it, sockets appear; lower it, extras get trimmed without touching existing connections.

    At run time the Python computes target = output_index % input_count (indexes past the count wrap), then with use_last_input on - its default - it scans backward from your target toward clip_0 and returns the nearest connected input. That fallback is the same behavior across the pack: keep a wired slot at a low index and a mid-stack disconnect won't kill the run.

    Wiring it up

    • input_count - how many clip_N sockets exist; set this before connecting anything.
    • output_index - which CLIP passes through. Feed it from a counter to step between encoders.
    • use_last_input - defaults on; backward-fallback to the nearest connected lower slot.

    The single CLIP output plugs into a CLIPTextEncode's clip input. Two CLIP loaders into the switch, one encoder downstream, and the index decides which text encoder your prompt runs through per execution.

    Installing the pack

    ComfyUI-IterSwitch has no Python dependencies beyond ComfyUI itself - no requirements.txt, no downloads. A clone is the whole install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/younger15/ComfyUI-IterSwitch.git
    

    Restart ComfyUI after cloning so the web extension loads. If you prefer Manager, search "ComfyUI-IterSwitch"; for a pack this small it may not be in the registry, in which case use Manager's install-by-Git-URL with the same link.

    Common issues

    • Fallback looks backward, not forward. use_last_input walks from your target down to clip_0. Only-connected-slots-above-target means None out, and a None CLIP will make CLIPTextEncode throw. Keep low-index slots wired.
    • Sockets missing after install. The dynamic inputs live in JavaScript, so a backend-only restart won't produce them - restart ComfyUI fully or refresh the page.
    • Silent wrap. output_index beyond the count wraps via modulo instead of warning. Fine for loops, easy to forget.

    Reality check: this pack is essentially undiscovered - none of its nodes show any search-console impressions, and there's no community track record to lean on. If the CLIP-swap use case is real for you, the code is simple enough to trust; if fallback misbehaves, the repo's issue tracker is the place to report it.

    CategoryCustomNodes/Iterators

    Inputs (3)

    NameTypeDefaultDescription
    output_indexINT00–18446744073709550000
    input_countINT21–64
    use_last_inputBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    CLIPCLIP