Nodes/ComfyUI-LZNodes/LZ String Select
ComfyUI Node

LZ String Select

Pick one of ten strings by index

By liz-ils·Created 7 months ago·Updated 12 days ago· 1
LZ String Select
    • text
    count2
    select_index1
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8
    text9
    text10

    Sometimes you want a workflow that holds ten prewritten prompts - or ten artists, or ten filename labels - and routes one of them through based on an index. LZ String Select is the node for that: up to ten text inputs, a count that decides how many are active, and a select_index that picks which one comes out. It's the string-world version of an A/B switch, with the selector driven by a number instead of a button.

    The UI is where this node earns its keep. The pack's JavaScript watches count and hides the text inputs you're not using, so a node set to count: 3 shows three tidy boxes instead of ten empty ones. Set count up and they reappear. It's a genuinely nice touch for keeping the canvas clean.

    The inputs

    • count - 1 to 10, how many text inputs participate. Default 2.
    • select_index - 1-based, which input to output. Default 1.
    • text1text10 - the candidate strings.
    • Output: text - the chosen string.

    The behaviors worth knowing

    Indexing is 1-based, not 0-based - the first box is text1 and select_index: 1 returns it. If you're coming from any programming language, this will trip you up at least once. The JavaScript clamps select_index into the 1..count range visually, so you can't easily click yourself into an invalid state, but if you drive it programmatically from another node and feed it an out-of-range index, the Python side simply returns an empty string rather than erroring. That's the failure mode to watch: no crash, just an empty prompt flowing downstream, which can produce a silent blank image if you're not looking.

    The count and select_index widgets are plain integers, but because the inputs are optional you can also wire an INT from a counter node or a loop into select_index and cycle through prompts automatically across a batch - that's the pattern that makes this more than a manual dropdown. Build a rotation of subject prompts, feed the index from a loop, and each iteration of your workflow uses the next one.

    How it differs from the pack's other string logic

    There are two near-neighbors in this pack worth not confusing it with. StringConcatNode joins strings together; LZStringSelect chooses exactly one. And the prompt-replace family (LZPromptReplaceSingle etc.) randomize a placeholder from a list - if what you actually want is random selection rather than index-based, those do that for you and also substitute into a template. This node's job is deterministic selection by number.

    Installing it

    Part of the ComfyUI-LZNodes pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/liz-ils/ComfyUI-LZNodes
    

    Restart ComfyUI, or ComfyUI Manager → search "ComfyUI-LZNodes". No extra dependencies, no model downloads - it's pure string routing with a bit of frontend polish.

    CategoryMyCustomNodes/Text

    Inputs (12)

    NameTypeDefaultDescription
    countINT21–10
    select_indexINT11–10
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING
    text5optSTRING
    text6optSTRING
    text7optSTRING
    text8optSTRING
    text9optSTRING
    text10optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING