Text lines count [darkilNodes]
Count the lines in a text block — the loop-counter you didn't know you needed
- INT
Loop workflows have a recurring problem: knowing how many iterations to run. If your loop body is driven by a newline-separated text block - a list of prompts, a list of filenames, a list of LoRA names - this node turns that block into a plain INT count you can feed straight into a loop's iteration count. It's the smallest node in this pack and possibly one of the most useful, because it removes the manual "let me count the lines myself" step from batch graphs.
How it works
It takes one input, text (STRING), and returns len(text.splitlines()) - the number of lines in the string, using Python's splitlines(), which handles \n, \r\n, and the rest correctly. A single-line string returns 1, an empty string returns 0, and a block with trailing newlines counts exactly the lines that have content. There's no trimming, no filtering - it's a raw, honest line count.
The output is a single INT. Wire it into anything that wants a count: a loop's iterations, a batch node's batch_size, or a conditional that behaves differently past N lines.
Where it shines
The canonical pattern: you've got a Strings Joiner (also in this pack) or a text block listing one prompt per line, and a repeat/batch loop that needs to process them one by one. Rather than hardcoding "I have 8 prompts," you wire Text lines count into the loop and the graph self-adjusts when you add or remove a line. Combined with the pack's Files list from dir, you can even count files as text lines and drive a processing loop off a folder scan - two tiny nodes replacing a whole hand-rolled loop harness.
Where people get burned
The count is a count of lines, not of items separated by commas or spaces. Feed it a comma-separated list and you get 1, not 6. And it counts blank lines too - if your list has trailing newlines or intentional empty lines, the number will be higher than the number of "real" entries. When the count feeds a loop, that mismatch usually shows up as one extra (or missing) iteration, which is easy to debug but easy to miss at a glance.
Installing
Ships in pytraveler/comfyui-darkil-nodes. ComfyUI Manager search ComfyUI-darkil-nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/pytraveler/comfyui-darkil-nodes
Restart ComfyUI. No Python deps, no models - a one-line stdlib string operation wrapped in a node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |