Nodes/ComfyUI-RvTools_v2/String from List
ComfyUI Node

String from List

Grab prompt #3 out of a list without the spreadsheet

By r-vage·Created about a year ago·Updated 5 months ago· 23
String from List
    • list item
    • size
    • wraps
    list_input
    index0

    Prompt batching is one of those ComfyUI superpowers that lives behind an awkward API. You feed a list of prompt strings into a CLIP Text Encode and get one generation per prompt - but if you want to pick one specific prompt out of that list mid-flow, you need something to do the picking. String from List is that something. Give it a list of strings and an index, and it hands back the item at that position, plus the list's size and how many times the index wrapped around. Original design borrowed from mr.pepe69's SelectStringFromListWithIndex, per the source.

    How it works

    Two inputs:

    • list_input - a list of strings (STRING). This node is list-aware (INPUT_IS_LIST), so it expects a list of strings, not a single multiline string - wire it from a string-list source, a batch of prompt nodes, or a node that emits a list.
    • index - which item you want (default 0, range −999 to 999). Negative indices work: −1 gives you the last item.

    Three outputs:

    • list item - the chosen string. (It's returned as a list too, so it stays compatible with list-processing chains.)
    • size - how many items the list had. Handy for bounds-checking or building loops.
    • wraps - how many full times the index went around the list. Index 3 on a 3-item list wraps once; the node clamps to the list and tells you it did.

    The wrap-around math is the interesting bit: any index is reduced modulo the list length and reported via wraps, so out-of-range indices never crash the node - they just point somewhere sensible and tell you about it. (If the list is empty, it returns empty results and logs a warning rather than dying.)

    Why you'd reach for it

    The killer use is index-driven prompt selection. Combine it with a loop or a seed-driven index and you can rotate through a set of prompts across a batch - prompt 1 on run one, prompt 2 on run two - without rebuilding the graph. It's also just the polite way to pluck an item when a downstream node wants one string but your source produces a list. Pair the size output with logic nodes and you can make decisions based on how many candidates you actually have.

    A caveat about lists

    This works on lists, not on a single multiline text box. If you feed it one big string with newlines, it sees a one-item list - you'll get the whole thing back, size = 1, and no real selection happening. Make sure whatever feeds list_input is genuinely producing a list of separate strings, not one blob with newlines in it.

    Installing it

    Part of the RvTools v2 pack - no model files. ComfyUI Manager → search RvTools → install ComfyUI-RvTools_v2, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/r-vage/ComfyUI-RvTools_v2
    

    Restart and confirm RvTools v2: Version 2.5.x in the console. Extra deps (opencv-python, pilgram, pynvml, piexif) install automatically via Manager.

    Troubleshooting

    • "Empty input list" warning → you fed it an empty list; returns empty item and size 0.
    • Whole-string-instead-of-item problem → your source isn't producing a real list (see the caveat above).
    • Old v1 RvTools references fail in Manager - the original repo was deleted; v2 renamed everything. The author's successor project, ComfyUI_Eclipse, supersedes this pack for new builds.
    Category🫦 RvTools II/ Text

    Inputs (2)

    NameTypeDefaultDescription
    list_inputSTRING
    indexINT0-999–999

    Outputs (3)

    NameTypeDescription
    list itemSTRING
    sizeINT
    wrapsINT