Nodes/ComfyUI_Inteliweb_nodes/String Index Selector (Inteliweb)
ComfyUI Node

String Index Selector (Inteliweb)

Pick one of ten prompts with a single integer

By maoper11·Created about a year ago·Updated 9 days ago· 4
String Index Selector (Inteliweb)
    • string
    • SELECTED_INDEX
    string_1
    string_2
    string_3
    string_4
    string_5
    string_6
    string_7
    string_8
    string_9
    string_10
    index1

    Sometimes a switch is a dropdown, and sometimes it's just a number. String Index Selector is the "just a number" kind: ten multiline text fields, one integer index, and it hands you the string at that position. No fancy matching, no dropdown - the index itself is the selection, which makes it trivially drivable by anything upstream that produces an integer.

    How it works

    The node holds string_1 through string_10, and an index widget (INT, default 1, min 1, max 10). At execution it clamps the index into 1..10 and returns the matching string along with the effective index. One-based, so 1string_1 and 10string_10 - there's no zero slot, and this is where people who come from code occasionally fumble.

    The reason it's more than a fancy lookup: both the ten string widgets and the index widget can be converted to input sockets. Convert the index and you can drive the selection from an upstream counter, a batch loop, or even a slider on another node. Convert the strings and you can pipe prompt variants in from elsewhere. That's the pattern that makes it a real routing node instead of ten hardcoded boxes.

    Inputs and outputs.

    • string_1string_10 - multiline STRING options.
    • index - which one to select (INT, 1–10).

    Outputs: string (the selected text, unchanged) and SELECTED_INDEX (the INT that was actually used, after clamping). The second output is handy if you want downstream logic to know which option won - for example, feeding a seed or a filename suffix from the same integer.

    Installing it

    Part of the Inteliweb pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/maoper11/comfyui_inteliweb_nodes.git
    cd comfyui_inteliweb_nodes
    python -m pip install -r requirements.txt
    

    Or ComfyUI Manager → "ComfyUI_Inteliweb_nodes". Just psutil and nvidia-ml-py, no model downloads, restart ComfyUI.

    Where people get caught

    The off-by-one is the classic: index 0 gets clamped up to 1, so a "zero" selection silently becomes string_1 - if your upstream counter is zero-based, add one before wiring it in. Second, a blank or unconnected string field returns an empty string, not an error, so you can have "slots" you haven't filled yet without crashing the graph. And remember the strings don't auto-trim: leading/trailing whitespace in a field comes through the output, which can quietly break a downstream prompt encoder if you pasted text with stray newlines. It's a small, single-purpose node, but when you need "pick a prompt variant by number," it's the whole answer.

    CategoryInteliweb/Text

    Inputs (11)

    NameTypeDefaultDescription
    string_1STRINGString option 1.
    string_2STRINGString option 2.
    string_3STRINGString option 3.
    string_4STRINGString option 4.
    string_5STRINGString option 5.
    string_6STRINGString option 6.
    string_7STRINGString option 7.
    string_8STRINGString option 8.
    string_9STRINGString option 9.
    string_10STRINGString option 10.
    indexINT11–10Selects string_1 through string_10. Uses one-based indexing.

    Outputs (2)

    NameTypeDescription
    stringSTRING
    SELECTED_INDEXINT