Nodes/zsq_prompt/Index String
ComfyUI Node

Index String

Pick one of ten wired strings by number, for loops and A/B tests

By windfancy·Created 2 years ago·Updated 5 months ago· 2
Index String
    • text
    index0
    text0
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8
    text9

    Index String (IndexString) from the zsq_prompt pack is a switch for text: it takes up to ten strings (text0 through text9) wired in from elsewhere, and a single index integer, and outputs whichever string that index points to. Nothing gets generated, nothing gets rewritten - it just selects. Which sounds boring until you want to A/B test five different prompts or feed a different style into every generation of a batch without editing nodes by hand.

    How it works

    The node declares ten optional string inputs and an index slider (0–9). When it runs, it builds the key "text" + str(index) and returns whatever is wired into that slot. That's the whole mechanism - a dictionary lookup over pre-wired inputs.

    One detail shapes how you use it: the ten text inputs are forceInput, meaning you can't type into them directly. They exist to be wired from other string nodes - a prompt string, a StringInput, another selector's output. This node is a router for a graph, not a place to type text.

    Inputs and outputs that matter

    • index - which slot to select, 0 to 9. This is the input you'll actually drive, often from an INT node or a math operation.
    • text0 … text9 - the candidate strings, wired in.
    • Output: text (STRING) - the selected string.

    Where it fits

    • Prompt A/B testing. Wire ten prompt variants into text0text9, drive index with a seed or a counter, and batch out a comparison set.
    • Batch variation. Pair it with a per-batch index (e.g. from a BatchPromptJson or a batch-count node) so each generated image in a batch uses a different prompt.
    • Style routing. Keep one selector feeding a sampler's positive, and swap styles by changing a single integer instead of rewiring.

    It sits in the same family as the pack's OptionString (which transforms text) and ConnectionString (which joins text). IndexString is the one that just picks. If you need more than ten options, stack two of them and cascade the output.

    Installing zsq_prompt

    Shared pack install. ComfyUI Manager → search zsq_prompt → install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/windfancy/zsq_prompt
    

    Restart ComfyUI. Heavy shared deps (transformers, opencv-python, opencv-contrib-python, scikit-image, timm, onnx, ultralytics) come with the pack. If Manager flags "conflicting with zsq_prompt" on a workflow, that's dependency-overlap noise; only meaningful once the pack is actually installed. No model downloads needed.

    Gotchas

    • The category in ComfyUI is literally "ZSQ/Stinrg" - yes, that's a typo in the pack, "Stinrg" not "String." You'll find these nodes under the misspelled menu.
    • forceInput means the slots must be wired; an unwired slot that gets selected returns the literal key name ("text3", say) rather than empty - wire what you plan to select.
    • Index beyond the wired range just picks a missing slot and gives you a nonsense key. Keep the index within the slots you've actually connected.
    CategoryZSQ/Stinrg

    Inputs (11)

    NameTypeDefaultDescription
    indexINT00–9
    text0optSTRING
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING
    text5optSTRING
    text6optSTRING
    text7optSTRING
    text8optSTRING
    text9optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING