PD String Line Count
How many items are on this wire? It tells you.
- line_count
Count how many things are on a string wire. PD String Line Count takes a text input and outputs an integer - the line count, or rather, the item count. And here's the honest version of what it actually does, because the name oversells it slightly: it counts the items in the list it receives. When you feed it a list output from the pack's batch text nodes, it tells you the batch size. When you type a multi-line string straight in, it comes through as a single item - so you get 1, not the number of lines.
The source even documents both intentions (count list items or count lines of a single multi-line string), but the code as written only does the first. It's a "how many prompts am I about to generate" / "how many files did the loader hand me" meter, and that's genuinely useful even if the name oversells.
How it works
The node declares INPUT_IS_LIST = True, which means ComfyUI hands the function the whole list rather than running it per item - exactly the setup you want for "report the size of the batch." It returns len(text) as an INT. Empty input returns 0. So:
- Wire it to a list-output node (like the pack's
PD: Random Promptor a batch text loader) → you get the number of items in that batch. - Type multi-line text directly → you get
1, because the widget value is one item.
That second case is the one that trips people. If you actually need "number of newlines in this string," this isn't the node.
The input and output
text(STRING, multi-line, forced as input socket).- Output:
line_count(INT).
A natural use: feed the count into a display node, a batch-size check, or a workflow gate that needs to know "did anything come through this time."
Installing it
Part of Comfyui_PDuse by 7BEII. ComfyUI Manager (search "PDuse") or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Restart. No models; pack deps are numpy, Pillow, scipy, opencv-python, torchvision. Docs are Chinese-first.
Where people get burned
The list-vs-lines distinction, full stop. If you wire a plain PD:String output into it expecting a line count of a paragraph, you'll get 1 and wonder what broke. Wire it to an actual list-output node and it's accurate. When in doubt, check the type of what's upstream - if the source declares OUTPUT_IS_LIST, this node counts it correctly; if it's a bare STRING, you're counting items, not newlines.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| line_count | INT | — |