Boyo Get Line By Number
Pull One Prompt Out of a List, Driven by a Counter
- line
BoyoGetLineByNumber is the node that turns a big block of prompts into a queue you can index into. You paste a multiline list, pick a line number, and it hands you that single line as a clean STRING. On its own that's mildly handy. Combined with a counter or loop node it's the engine of batch workflows: generate a different prompt every frame, iterate through a shot list, or feed one LoRA-caption line at a time into a pipeline.
The mechanism is deliberately simple. It splits the text on newlines, strips whitespace from every line, and drops blank lines entirely - so a ragged text block with stray empty rows indexes the way you expect rather than the way your text editor laid it out. Then it grabs the line at the index you asked for. Two behaviors worth knowing: the index is 0-based (line 0 is the first line), and out-of-range indices are clamped instead of erroring - an index past the end returns the last line, a negative index returns the first. That makes it safe to drive from a counter that runs past the end of your list; you get a repeated last prompt rather than a crash.
The inputs are where this earns its keep:
text- the multiline source, connected as a socket (forceInput), not typed into a widget.line_index- the widget value, 0 by default.line_index_override- the interesting one. It's an optional socket that, when connected, overrides the widget entirely. Drive it from a loop counter, a frame counter, or a seed-driven value and you've got deterministic per-iteration prompt selection.
The single output is line (STRING), which feeds a text encoder, a prompt builder, or any downstream string socket.
Installing it
It ships in the Boyonodes pack - search Boyonodes in ComfyUI Manager, or clone manually:
cd ComfyUI/custom_nodes
git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes
Restart and you're done. This is a text node; it needs nothing beyond what ComfyUI already has. The pack's long requirements.txt is all audio/video/LoRA extras you can ignore for this corner.
Where people get burned
- 0-based indexing. If your list has ten prompts and you ask for line 10, you get the last one, not an error. Ask for line 1 expecting the second prompt and you'll grab the first. Off-by-one is the #1 footgun here.
- Blank lines vanish. A double newline between prompts doesn't create a phantom line - it's skipped. Paste clean lists and index counting becomes trivial.
- It only reads one line at a time. If you actually want the whole block passed through, that's BoyoMultilineText's job; this node is the selector.
Pair it with a counter node from the same pack and you get the classic "one prompt per iteration" loop without touching a Python node. It's a small tool, but it's the small tool that makes the batch workflows work.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| line_index | INT | 00–999999 | — |
| line_index_overrideopt | INT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| line | STRING | — |