Nodes/ComfyUI-YogurtNodes/String Lines Count (Yogurt Nodes)
ComfyUI Node

String Lines Count (Yogurt Nodes)

Count the lines in your prompt lists, so your workflow knows how much it's about to do

By yogurt7771·Created 2 years ago·Updated 4 days ago· 1
String Lines Count (Yogurt Nodes)
    • count
    • text1
    • text2
    • text3
    • text4
    • text5
    • text6
    • text7
    • text8
    no_stripfalse
    keep_empty_linesfalse
    concat_methodconcat
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8

    You've got a multiline text box with ten prompts in it, one per line, and you're about to feed them into a batch scheduler. Wouldn't it be nice if the workflow itself knew there were ten? That's the whole job of YogurtStringLinesCount: it tells you how many lines are in a multiline string, so the rest of the graph can react to the size of its own input.

    Why you'd reach for it

    Batch workflows get unwieldy fast. You paste a prompt list, wire it to a LatentFromBatch or a scheduler, and then eyeball "how many did I put in there?" whenever you change it. This node turns that into a real signal: the count output is an INT you can use to set a batch size, drive a YogurtRange, or guard a loop. It's the difference between a graph that just runs and one that knows what it's running.

    How it works

    Up to eight multiline text1text8 inputs go in, and the node splits them on line breaks and reports the total as count (INT). Two toggles control what counts as a line:

    • no_strip - when off (default), lines are stripped of surrounding whitespace before counting, so a line of just spaces doesn't inflate your total. Flip it on if whitespace genuinely matters.
    • keep_empty_lines - when off (default), empty lines are skipped. Turn it on if you're using blank lines as intentional separators and want them counted.

    There's also a concat_method dropdown with concat and product. Leave it on concat unless you know what you're doing - product is a cartesian-combination mode that exists for the pack's fancier matrix workflows, and it's not what you want when you just need a line count.

    The node also echoes text1text8 back out, so it can sit inline in a chain without you having to reroute the originals around it. Handy when you're counting in the middle of a pipeline rather than at the end. And yes, this is an output node - it's meant to be looked at, so it shows up as a display in the graph.

    Where the count goes

    Common wiring: count → batch-size input on your sampler or an ImageBatch → so the batch always matches the prompt list. Or count → a conditional that skips an upscale pass when you're only generating one image. It's a small node, but it removes a whole class of "wait, I only fed it five, why did it render eight" moments.

    Installing it

    Install the Yogurt Nodes pack once - via ComfyUI Manager (search "ComfyUI-YogurtNodes") or manually:

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

    Restart ComfyUI and you'll find it under YogurtNodes/String. No model downloads, no API keys - this one is pure Python string handling.

    Gotchas

    Empty input is not a crash - an empty multiline box counts as zero lines, so the node won't blow up on an unset prompt list. And with the defaults (keep_empty_lines off, no_strip off), a trailing newline doesn't count as a phantom line, since empty and whitespace-only lines get skipped. If your count is consistently one higher than you'd expect, check that there isn't a stray blank line hiding at the end of the box - that's the usual culprit.

    CategoryYogurtNodes/String

    Inputs (11)

    NameTypeDefaultDescription
    no_stripBOOLEANfalse
    keep_empty_linesBOOLEANfalse
    concat_methodCOMBOconcat2 options: concat, product
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING
    text5optSTRING
    text6optSTRING
    text7optSTRING
    text8optSTRING

    Outputs (9)

    NameTypeDescription
    countINT
    text1STRING
    text2STRING
    text3STRING
    text4STRING
    text5STRING
    text6STRING
    text7STRING
    text8STRING