๐ผ> Text Pick Line by Index
Grab one specific line out of a multiline prompt list
- text
If you've got a multiline text box full of prompt variants, tags, or captions - one per line - this node pulls out exactly one line by its position, rather than the whole block. It's the deterministic counterpart to YANC's Text Pick Random Line: same idea of treating a text box as a list of lines, but here you choose which line comes out, driven by a number instead of a seed.
That makes it the node to reach for when you're stepping through a fixed list on purpose - pairing an incrementing Primitive on index with a Load Image From Folder-style batch pass, so line 1 of your text list matches image 1, line 2 matches image 2, and so on, rather than getting a random line every time.
How it works
The text input is split into lines. index picks which line comes out - counting starts from whichever end direction points at. direction set to top bottom counts from the first line down; bottom top counts from the last line up, which is handy if you're appending new lines to the bottom of a list and want to always grab the newest one at index 0 without recalculating the list length.
The inputs and outputs that matter
text- the multiline source, one item per line.index(INT) - which line to pick, zero-indexed from whichever enddirectionselects.direction-top bottomorbottom top, controlling which endindexcounts from.
One output: text, the single selected line - feed it into a CLIP Text Encode, a Save Image filename, or a Text Combine to merge with something else.
How to install it
Via ComfyUI Manager: search "yanc" or "YANC - Yet Another Node Collection," install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ALatentPlace/ComfyUI_yanc
then restart. Pure text processing, no extra dependencies.
Common issues & troubleshooting
Wrong line comes out. The most common cause is direction being set the opposite of what you assumed - an index of 0 with top bottom gets the first line, but the same index of 0 with bottom top gets the last line. If your output looks off by exactly "the whole list reversed," that's almost certainly the culprit.
Index out of range. If your text box has fewer lines than the index you set (say your list has 5 lines but index is set to 7), the node has nothing valid to return - keep the index in sync with however many lines are actually in the source text, especially if that text is coming from a dynamic upstream source rather than something you typed by hand.
Blank lines throw off the count. Empty lines in the source text box still count as lines for indexing purposes. If your prompt list has stray blank lines between entries (easy to introduce by accident when pasting from elsewhere), your intended "line 3" may actually land on an empty string. Worth a quick visual check of the raw text box if picks look wrong.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | โ | |
| index | INT | โ | |
| direction | COMBO | 2 options: top bottom, bottom top |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | โ |