Nodes/Text Line Selector/Text Line Selector
ComfyUI Node

Text Line Selector

Step Through Prompts Without Touching the Graph

By TuriSc·Created 10 months ago·Updated 10 months ago· 2
Text Line Selector
    • selected_line
    • index
    multiline_text
    line_index1
    control_after_generateincrement

    You've got a positive prompt you want to vary across a run - a new subject, a different style, a list of faces - but you don't want to rebuild the graph for each one. Paste all your variations into one multiline box, wire one node into your text encoder, and click Run until the list is done. That's the whole pitch of Text Line Selector: it pulls one line out of a multiline string and hands you a way to step to the next one after each generation.

    It sits in the utils category, which is exactly the right home. Like the rgthree-style quality-of-life nodes, it adds nothing you can generate with - it exists so a workflow you'd otherwise edit by hand stays runnable. The control_after_generate dropdown is borrowed from the old A1111 ControlNet convention, so if you've seen one of those before, this will feel familiar immediately.

    How it actually works

    The split is clever in a way that matters for how you'll use it. The Python side is dumb and predictable: it splits multiline_text on newlines, treats line_index as 1-based (1 = first line), wraps out-of-range indexes with a modulo, and returns the selected line plus the index it used. All the "after generate" behavior lives in the bundled JavaScript. When you hit Queue, the JS intercepts it and - after the run is submitted - rewrites the line_index widget according to your dropdown: next line, previous line, or a random line that skips the current one. The node you see on screen is already pointing at the next line before you click again.

    That's why the README's warning is real and not a bug: the stepping fires once per queue click, not once per batch item. ComfyUI caches a node's result within a batch, so if you set Batch Count to 5 hoping for five different lines, you get the same line five times. The correct pattern is Batch Count 1, Run repeatedly.

    The inputs and outputs that matter

    Three inputs, and only one of them is interesting:

    • multiline_text (STRING, multiline) - your list, one entry per line.
    • line_index (INT, default 1) - which line to start on. You rarely touch this; the node advances it for you.
    • control_after_generate - fixed, increment, decrement, or randomize. increment is the default and is what you want 90% of the time.

    Outputs are selected_line (STRING) and index (INT). Wire selected_line straight into a CLIP Text Encode node - or into a String Concatenate if you're building prompts out of parts - and ignore index unless you need to log which entry ran.

    Installing it

    Install via ComfyUI Manager (search "Text Line Selector") or the usual manual route, then restart:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TuriSc/comfyui-text-line-selector
    

    Good news: it has zero Python dependencies and downloads no models - it's pure string handling, so there's nothing to break.

    Where people get burned

    • Batch Count > 1 gives you one line, repeated. The single most confusing part of this node, and the README calls it out correctly. One run, one line.
    • Trailing newlines count as lines. The split keeps empty lines, so a multiline box that ends with Enter will occasionally hand your text encoder an empty string and, more confusingly, the JS steps through that empty slot as if it were real. Trim your trailing newline.
    • It's a small, quiet pack. This node won't show up in most "must-install" lists and has almost no Google footprint - if it clicks for you, don't be surprised nobody else mentioned it. It's a simple idea, done competently, with one real gotcha.
    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    multiline_textSTRINGEnter multiple lines of text, each line will be processed individually
    line_indexINT11–999999Line number to extract (1 = first line, 2 = second line, etc.)
    control_after_generateCOMBOincrementHow to modify the index after generation: fixed (no change), increment (next line), decrement (previous line), or randomize (random line)

    Outputs (2)

    NameTypeDescription
    selected_lineSTRING
    indexINT