Nodes/ComfyUI-BETA-Cropnodes/Text line count πŸ…‘πŸ…”πŸ…£πŸ…
ComfyUI Node

Text line count πŸ…‘πŸ…”πŸ…£πŸ…

A line counter for multiline text β€” the smallest useful node in the pack

By Burgstall-labsΒ·Created about a year agoΒ·Updated 6 months agoΒ· 8
Text line count πŸ…‘πŸ…”πŸ…£πŸ…
    • line_count
    β—„textβ–Ί

    Text line count takes a multiline text input and returns how many lines it has. That's the whole node - a STRING in, an INT out. It sounds almost too small to write an article about, but it's one of those utility nodes that quietly earns its place once you've loaded a workflow that needs a number derived from text and you're reaching for a math node to fake it.

    The practical uses are the boring ones that still save you time: you loaded a list of prompts from a text file and want to know how many there are before you feed them into a batch loop. You're sanity-checking that a caption file came through with the expected number of entries. You want a workflow that warns you when a prompt list is empty (the node returns 0 for an empty string, so it plays nicely with conditionals). In all of those, this converts "let me count the lines in my head" into a number that the rest of the graph can actually use.

    It's part of Burgstall-labs' BETA helper pack - a small, MIT-licensed grab bag of video and text utilities from the "Burgstall Enabling The Awesomeness" suite, which is why the node name carries the πŸ…‘πŸ…”πŸ…£πŸ… branding. No models, no heavy dependencies, nothing to configure.

    How it works

    The mechanism is a one-liner: it splits the text with Python's str.splitlines() and returns the length. The detail worth knowing is that splitlines() correctly handles all three newline conventions - \n, \r\n, and old Mac-style \r - so text from Windows files, Linux files, and weird exports all count the same. No off-by-one games with trailing newlines.

    Inputs and outputs

    • text - a multiline string widget (it renders as a text box in the UI). Paste your list, or wire it from a Load Text node or anywhere else that produces text.
    • line_count (INT) - the number of lines. Wire it into anything that takes an integer: loop counts, batch sizes, or a display node so you can see the number on the graph.

    There's genuinely nothing else to set. That's the appeal.

    Install

    It ships in the same pack as everything else from Burgstall-labs, so installing it means installing ComfyUI-BETA-Helpernodes. ComfyUI Manager is the easy route - search "BETA-Helpernodes". Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Burgstall-labs/ComfyUI-BETA-Helpernodes.git
    

    Then restart ComfyUI. One thing to know: this node itself needs nothing - no opencv, no scenedetect, nothing beyond base ComfyUI. But the pack's requirements.txt installs those anyway (they're for the video nodes), and the pack was previously published under the name ComfyUI-BETA-Cropnodes. If you ever had that old folder, delete it and reinstall under the new name so you don't end up with two copies fighting.

    Any gotchas?

    Not really. The only thing that trips people up is expecting it to count characters or words - it counts lines, period, and it counts an empty string as zero. If you need word counts, that's a different node; this one is happy being tiny. It's the kind of node that makes you wonder why you installed a whole pack for it - until you remember it was free, it's dependency-free, and now the count is just one wire away.

    CategoryBETA Nodes

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    line_countINTβ€”