Nodes/comfyui_bmad_nodes/FromListGet1String
ComfyUI Node Runs on cloud

FromListGet1String

Pick one string out of a list for prompt roulette — FromListGet1String

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
FromListGet1String
    • STRING
    list
    index0

    FromListGet1String is the text member of Bmad's "grab one item by index" list family: a STRING list in, one string out, index decides which. It's the node you reach for when you want to cycle, shuffle, or deliberately pick between prompt variations without stringing together a pile of switch nodes.

    The concrete use case is prompt roulette. Build a list of seed-style fragments with ToStringList (same pack, Bmad/Lists/Make or Intercalate), pipe it into FromListGet1String, drive the index from a random int node - and now each generation pulls a different phrase into your prompt. Feed the index from a slider and you've got a manual "flip through variants" dial. Because the string output feeds a normal CLIP text encoder socket, the rest of your graph doesn't change at all; you're only swapping out the text. Same trick works for negative prompts, LoRA trigger words, or filenames if you're building save paths.

    How it works

    It's the same GetSingleFromListMeta machinery as the other FromListGet1X nodes. INPUT_IS_LIST is set, and the entire pick is:

    index = index % len(list)
    return (list[index],)
    

    Two behaviors matter. Negative indexes work - -1 is the last string, -2 the second-to-last. And out-of-range indexes wrap instead of failing, so index 5 on a three-item list returns item 2. That's a deliberate convenience for driving the node from a random or stepped counter: no bounds checking needed. The only way to break it is to feed an empty list.

    Inputs and outputs

    • list - a STRING list, marked forceInput, so there's no text box on the node. You have to wire a list from ToStringList or ExtendStringList (or another pack's string-list producer).
    • index - an INT, default 0, minimum -2147483648, which exists mainly to give negative indexing headroom.
    • Output: one STRING, ready for a CLIPTextEncode or any other string input.

    Install

    This is part of bmad4ever/comfyui_bmad_nodes. In ComfyUI Manager, search "comfyui_bmad_nodes" (it shows up as "Bmad Nodes"), install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_bmad_nodes
    cd comfyui_bmad_nodes
    pip install -r requirements.txt
    

    Restart ComfyUI afterward. No models involved - the requirements (opencv-python, scikit-image, simpleeval, gray2color) are pure pip packages.

    Common issues

    The usual miss is trying to type into the list input - it won't accept a plain string, only a list connection, because of forceInput. Second gotcha is the wrap-around index: if you expect an out-of-range value to error so you can catch it, it silently cycles instead. If you want strict "stay within the list," clamp the index yourself. Otherwise this is a dead-simple utility; the only real skill is remembering it exists when you're about to build your seventh switch node.

    CategoryBmad/Lists/Get1

    Inputs (2)

    NameTypeDefaultDescription
    listSTRING
    indexINT0

    Outputs (1)

    NameTypeDescription
    STRINGSTRING