Text File Line Counter ⏲️
Count lines in a text file without opening it
- INT
- FLOAT
- STRING
This one does exactly what the name says: give it a file path, it counts the lines and hands the number back into your graph. The pack's README pitches it as good for "analyzing logs, scripts, and more," and that's the honest scope of it - this isn't parsing anything, it's not validating content, it's just answering "how many lines does this file have" without you opening it in a text editor to find out.
The reason that's useful inside ComfyUI specifically: text files show up as inputs all over automated workflows - wildcard files, prompt lists, batches of captions for training data. If you're about to drive something off every line in a prompt list, you generally need to know how many lines there are first, whether that's to set a batch total, cap a loop, or just sanity-check that the file you pointed at isn't empty before a long run chews through it.
How it works
file_path points at a plain text file on the filesystem the workflow is executing on. The node opens it and counts lines. That's it - there's no parsing logic, no filtering blank lines out, nothing schema-level that hints at special handling. Keep it to actual text files; handing it a binary file (an image, a model, anything that isn't plain text) isn't something the node is built to make sense of.
The inputs and outputs that matter
One input: file_path (STRING, empty by default) - the file to count.
Three outputs carrying the same count in different types - INT, FLOAT, STRING - pick whichever one your next node actually accepts.
Installing it
ComfyUI Manager: search ComfyUI-Line-counter, install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/ChrisColeTech/ComfyUI-Line-counter.git
Restart ComfyUI afterward. Nothing to download, no dependencies - it's a file-read operation, not a model.
Common issues and troubleshooting
Same rule as any node with a bare file_path text box: it has to be a real path on the machine actually running the workflow, and there's no browse button to catch a typo for you. If you're pointing it at a local file, that means the machine running ComfyUI, not necessarily the one you're viewing the UI from.
Line counting has one classic ambiguity worth knowing about regardless of which tool does it: whether a trailing newline at the end of the file counts as an extra "line" or not can differ by exactly one depending on how a file was saved. If your count is off by one from what you expected, that's the first thing to check - not a bug, just how text files and line-counting logic interact in general.
And because there's no encoding option on this node, stick to plain UTF-8 text files. A file saved in some unusual encoding is more likely to error out than to be handled gracefully, since there's nothing in the inputs to tell the node which encoding to expect.
If you're chaining this into a loop - count the lines, then use that total to drive something like Simple Number Counter or a queue-trigger node through that many iterations - remember this node only reports the count once per run. It's not watching the file for changes; if the file grows mid-workflow, you'll need to re-run the counter to pick up the new total.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |
| FLOAT | FLOAT | — |
| STRING | STRING | — |