Nodes/Bjornulf_custom_nodes/๐Ÿ”ข Add line numbers
ComfyUI Node

๐Ÿ”ข Add line numbers

Know exactly which line is coming next in a sequential loop

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐Ÿ”ข Add line numbers
    • STRING
    โ—„textโ€”โ–บ

    This node does exactly what it says and nothing more: give it a block of text and it prepends a number to every line. On its own that's a minor convenience. Paired with Bjornulf's Loop Sequential (input Lines) node, it's genuinely useful - that loop only shows you the current line each run, one queue at a time, with no visibility into what's coming. Number the source text ahead of time, and you always know exactly which line you're about to hit next, and how many are left.

    How it works

    There's no configuration to speak of. Feed it multiline text, and each line gets a number attached at the start - the same source you'd otherwise feed straight into a sequential-line loop. The pack's own README points at this specific pairing directly: "if you want to be able to predict the next line, you can use [this node]." That's the entire use case in one sentence.

    The reason it matters: Loop Sequential (input Lines) is a one-line-per-queue-run node - click Run once, get line one; click again, get line two - and it uses +1/-1 buttons to move manually through the list, including re-running a line you didn't like (say, after tweaking a TTS setting and wanting the exact same sentence again). Without numbers on the source text, tracking "which line am I currently on, and what's three lines ahead" means counting manually every time you scroll through a long block. With numbers baked in, it's a glance.

    The inputs and outputs that matter

    • text (required, multiline STRING) - the block of text to number, one entry per line.
    • Output - a single STRING, the same text with a number prepended to each line.

    That's the whole node. No optional inputs, no widgets to configure.

    How to install it

    ComfyUI Manager โ†’ search Bjornulf_custom_nodes โ†’ install โ†’ restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/justUmen/Bjornulf_custom_nodes
    pip install -r Bjornulf_custom_nodes/requirements.txt
    

    Plain string processing, zero special dependency - it loads regardless of whether the pack's heavier optional deps (ffmpeg, ollama, and so on) are installed.

    Common issues & troubleshooting

    The numbers don't match what the sequential loop node is showing me. Make sure you're numbering the exact same text you're feeding into the loop - if you edit the source list after numbering it (add or remove a line), the numbers you're looking at are now stale relative to the loop's actual position.

    I don't need this if I'm just eyeballing a short list. Fair - its value scales with list length. For five or six lines, counting by eye is fine. For a fifty-line script you're feeding through a TTS loop one sentence at a time, this is the difference between glancing at a number and manually scrolling and counting every time you want to know what's next.

    Can I use this outside the sequential-loop use case? Sure, it's just line numbering - useful any time you want to visually reference specific lines in a long text block, independent of any loop. The pairing with Loop Sequential (input Lines) is simply the reason the author built it.

    CategoryBjornulf

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGโ€”

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGโ€”