Nodes/CRT-Nodes/String Line Counter (CRT)
ComfyUI Node

String Line Counter (CRT)

How many prompts are actually in that text block?

By PGCRT·Created 2 years ago·Updated 7 days ago· 129
String Line Counter (CRT)
    • INT
    text

    A small, honest utility node: feed it a block of text, get back the number of lines. That's the entire function, and the value is entirely in what it saves you from doing manually - counting lines by eye in a wildcard file, a prompt list, or a batch of captions before you commit to running something a hundred times over.

    Where it actually gets used

    This node lives in the pack's Text category alongside things like String Splitter, String Batcher, and Text Loader Crawl Batch - nodes that read or split text into pieces for batch-style workflows. The natural pairing is feeding a newline-separated list of prompts (one per line) into this counter and using the result to drive something downstream: sizing a batch count automatically instead of hardcoding a number that goes stale the moment you edit the list, or as a quick sanity check before a long run - "did my wildcard file actually load all 40 lines I expect, or did something get truncated to 12?"

    It's also just a useful debugging tool on its own. If a batch process is producing fewer outputs than you expected, wiring this in early and checking the count against what you think you fed it is a fast way to rule out "the text didn't load right" before you go chasing a more complicated theory about the rest of the graph.

    The input and output that matter

    • text (STRING, multiline, default empty) - the block of text to count.
    • INT - the line count, unnamed beyond its type. Wire it into a batch-count field, a math node, or a Show/Display node just to check your assumption before running anything expensive.

    That's the whole node - one input, one output, no configuration to get wrong.

    How to install it

    Part of CRT-Nodes. Via ComfyUI Manager, search CRT-Nodes and install. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/PGCRT/CRT-Nodes.git
    pip install -r CRT-Nodes/requirements.txt
    

    then restart. As with every node in this pack, you're installing the full CRT-Nodes suite - a hundred-plus nodes across image FX, video sampling, audio and text tools - to get this one small counter, which is just how the pack ships rather than anything specific to this node.

    Common issues & troubleshooting

    Count is off by one from what you expect. This usually comes down to a trailing newline (or lack of one) at the end of your text block - depending on how the text was authored or pasted in, an extra blank line at the end can add one to the count. If the number looks slightly wrong, check the very end of your source text for a stray empty line.

    Feeding it something other than line-separated text gives a meaningless number. This node counts newlines, full stop - it has no concept of "prompts" or "entries" beyond that. If your list is comma-separated or uses some other delimiter, this won't count it correctly; you'd want a different splitting node for that format.

    Node doesn't show up after installing. Check the ComfyUI startup log for a CRT-Nodes import failure - a pack-wide dependency conflict is far more likely than anything wrong with a node this simple.

    CategoryCRT/Text

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    INTINT