Text Line Counter
One tiny node that finally tells you how many prompts you pasted
- original_text
- line_count
- processed_text
Every ComfyUI regular has hit this moment: you paste a list of prompts into a multiline box - one per line, maybe ten, maybe twenty - and then you want to loop over them. Except you have no idea how many there are, and the count of a multi-line string is exactly the thing ComfyUI refuses to tell you out of the box. Text Line Counter is a single-node fix for that, and honestly it's refreshing for how boring it is. No dependencies, no model files, no API. Just text in, a number out.
What it actually does
The pack is one node, TextLineCounter, and it does three things at once. It takes your text, strips out blank lines and lines that are only whitespace, counts what's left, and hands you back both the original and the cleaned-up version. The mechanism is three lines of Python - splitlines(), filter on line.strip(), rejoin with "\n" - which is exactly the right size for the problem.
Where people get burned: line_count counts non-empty lines, not lines in the box. The README (it's in Chinese, by the way, from a one-node utility author who clearly made this for their own workflows) is upfront about the "automatically skip blank lines" behavior. Paste five prompts separated by a blank line and you'll get 4, not 5. If you're feeding the count into a loop that iterates per prompt, that's the behavior you want - it means every iteration gets a real prompt. But if you expected a raw line count, it'll look like the node is lying. It isn't. It's just opinionated.
One subtler thing worth knowing: the filter checks each line with strip() but re-joins the original line text. So " hello " survives into processed_text with its spaces intact, while a line of pure spaces vanishes entirely. That's usually what you want; just don't assume it trims.
The inputs and outputs that matter
There's exactly one input: text_input, a multiline STRING. Drop your list of prompts, tags, filenames - anything you'd iterate over - in there.
The three outputs are:
original_text(STRING) - a passthrough of your exact input, handy when you want to keep the raw string on the wire without a reroute node.line_count(INT) - the number of non-empty lines. This is the one that matters. Wire it into a repeat count, a for-loop (the README explicitly calls out for-loop use), or a batch-size input and you've got prompt-variation iteration without eyeballing how many lines you typed.processed_text(STRING) - the blank-line-stripped version, ready to feed into a per-line text loader or a text splitter.
Installing it
This is the easy part. ComfyUI Manager → search "Comfyui-TextLine-counter" (or "Text Line Counter") → install, then restart. Or skip Manager entirely:
cd ComfyUI/custom_nodes
git clone https://github.com/zpengcom/Comfyui-TextLine-counter
Then restart ComfyUI. That's the whole install - there's no requirements.txt to fight with, which is a small mercy in an ecosystem where the most common operational complaint is dependency hell. Pure stdlib, no weights to download, nothing to configure.
Troubleshooting
Given the whole node is ~35 lines of Python, there isn't much to troubleshoot. The one thing that trips people up is the non-empty-line counting described above - if your loop count comes up short, check for blank lines in the box. And remember it counts lines, not words or prompts with commas inside them; a single wrapped line is one line. If you need to know whether a multi-line prompt list actually parsed into the N entries you expected, line_count is a cheap sanity check - and that alone is worth the install.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text_input | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| original_text | STRING | — |
| line_count | INT | — |
| processed_text | STRING | — |