Text Line Select
Pick a line from a text block by index or at random
- text
- text_list
- count
- selected
You've got a block of prompt variations and you want one of them - line 3 today, a random one tomorrow. That's the whole job of Text Line Select, and it's one of those nodes that feels trivial until you've wired it into a batch loop and realized it just saved you a custom script. It's a "Text Tools" node from the drmbt/comfyui-dreambait-nodes pack: paste a multi-line text block, pick a line by index or roll the dice, and it hands you the chosen line plus the full split list and count.
The random mode is the sleeper feature. Because the node forces a re-run every time random is enabled (IS_CHANGED always returns true), it actually re-rolls on every queue - which is exactly what you want for "generate a random one of these ten prompts per batch item," and exactly the kind of behavior a naive random in a node gets wrong. This one gets it right.
How it works
It splits your text on newlines, strips each line, and drops empty ones - so blank lines don't count toward the index, which is a detail that saves you from off-by-one headaches. Then it picks a line two ways:
- select - an index into the list. It loops with a modulo operator per the author's tooltip: feed it
7on a five-line block and you get line 2, not an error. That makes it safe to drive from a counter that outruns your line count, or from a seed. - random - true picks a random line instead, re-rolling each execution.
It's an output node, so it displays the resulting text in the UI - which is half the appeal if you use it as a quick "show me this text" display rather than for selection at all.
The inputs and outputs that matter
- text - the multi-line block (requires a wired input, not typed-in text).
- select - line index, modulo-wrapped. Default 0 = first line.
- random - boolean toggle; true bypasses
select.
Outputs:
- text - the full original block (pass-through).
- text_list - the split lines as a list, with empties filtered.
- count - how many lines survived the filter.
- selected - the chosen line. This is the one you wire into your prompt.
Installing
Text Line Select is one node in the drmbt/comfyui-dreambait-nodes pack. Install the pack via ComfyUI Manager (search comfyui-dreambait-nodes) or:
cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes
# restart ComfyUI
No models, no dependencies - pure text splitting.
Where it earns its keep
The canonical setup: a text block of ten prompt variations wired into this node, with random on, feeding a CLIP Text Encode - instant randomized prompt roulette, fully visible and editable in one place. Or drive select from a frame counter for scripted variation sequences. The text_list + count outputs make it usable as a general text-to-list utility too, so it pulls double duty. One thing to know: it's built for wired text (forceInput), so you can't just type into the text field and have it work - pair it with a primitive or another text node. And the modulo behavior, while handy, means a select value larger than your list won't error out loudly; if you were expecting an error to catch a bug, it won't. Small, predictable, and the random mode behaves the way people actually want it to.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| select | INT | 00–9223372036854776000 | Select which line to output (cycles through available lines). This number loops with a modulo operator. |
| random | BOOLEAN | false | When enabled, selects a random line instead of using the select index |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| text_list | STRING | — |
| count | INT | — |
| selected | STRING | — |