Text Split Lines (NH)
The ComfyUI text superpower
- lines
- selected
- count
- preview
- is_first
- is_last
Text Split Lines (NH) is the node in this pack that does something ComfyUI normally can't do easily: it treats text like a batch. You give it a list of prompts, one per line, and its lines output becomes a data list - connect it to any STRING input downstream and your graph runs once per line, like a batch of images but for text. Ten lines, ten renders, no extra nodes.
That's the headline. The other headline is that it also picks a single line for you, with modes and a preview, which makes it a strict upgrade over the pack's simpler Text Random Line when you want control rather than just a dice roll.
How it works
It splits your multiline text, strips whitespace, skips empty lines by default, then applies a mode to the order:
- sequential - keep the lines in order.
- shuffle - randomize order, seeded.
- reverse - flip the list.
Then it picks one line for the selected output. The index input drives it: a normal 0-based index picks that line, and -1 means random (using the seed). If wrap_index is on (default), an out-of-range index wraps around modulo the line count; turn it off and it clamps instead. The tooltip on the index field spells this out: "-1 = random (uses seed)."
The outputs:
- lines - the data list; this is the one that fans out into one execution per line.
- selected - the single line you asked for.
- count - number of lines.
- preview - a formatted listing showing every line with a
>>>marker on the selected one, so you can eyeball what you'll get before you queue. - is_first / is_last - booleans saying whether the selected line is at either end, useful for piping into logic.
The inputs that matter
You set four things most of the time: text (your list), index (which line, or -1 for random), mode (sequential/shuffle/reverse), and seed. The optional delimiter defaults to \n but you can switch to \t or anything else; skip_empty and strip_whitespace are on by default and you basically never touch them.
Where it's genuinely great
The killer workflow is prompt testing: paste 20 prompt variants, wire lines into a CLIP Text Encode, and ComfyUI renders each one in a batch - you get a contact-sheet-style sweep without building a single loop. It's the same "data list" mechanic image batch processors use, applied to text, and it's the reason this node exists at all.
Pair it with the pack's Image Grid Composite if you want the results laid out side by side, or use selected + index with a Switch N (NH) when you want to route rather than fan out.
Two honest gotchas. First, the cache: with a fixed seed and unchanged inputs, ComfyUI may hand you the same selected line on consecutive queues (this node doesn't force a re-run) - change the seed or the text to re-roll. Second, be deliberate with mode: shuffle reorders the lines list itself, not just the selection, so the batch order changes. If you want the batch order stable and only the pick to vary, use sequential.
Install
Part of NH-Nodes - ComfyUI Manager → search NH-Nodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
No models, no downloads. Pure text plumbing, and the one text node here I'd actually go out of my way to use.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | first prompt second prompt third prompt | — |
| index | INT | 0-1–9999 | Which line to pick for `selected`. -1 = random (uses seed). |
| mode | COMBO | 3 options: sequential, shuffle, reverse | |
| seed | INT | 00–4294967295 | — |
| delimiteropt | STRING | \n | — |
| skip_emptyopt | BOOLEAN | true | — |
| strip_whitespaceopt | BOOLEAN | true | — |
| wrap_indexopt | BOOLEAN | true | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| lines | STRING | — |
| selected | STRING | — |
| count | INT | — |
| preview | STRING | — |
| is_first | BOOLEAN | — |
| is_last | BOOLEAN | — |