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

String Lines Switch (Yogurt Nodes)

Pull line 3 out of a prompt list and feed it somewhere else

By yogurt7771·Created 2 years ago·Updated 5 days ago· 1
String Lines Switch (Yogurt Nodes)
    • string
    • int
    • float
    • count
    no_stripfalse
    keep_empty_linesfalse
    index0
    concat_methodconcat
    product_concat_delimiter
    product_order0,1,2,3,4,5,6,7
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8

    Every prompt-list workflow eventually needs one line out of the middle. You keep ten prompts in a multiline box, the graph runs one per iteration, and at some point you need "the prompt at position 4" as a standalone value - for a comparison, a save name, a conditional. YogurtStringLinesSwitch is the node that reaches into a multiline string, grabs the line you ask for, and hands it back to you as a string and a number. Description on the box: "Get line from multiline string by index." That's the whole deal.

    How it works

    Feed up to eight multiline text1text8 inputs, set index (an INT, default 0), and the node pulls the line at that position. Then it hands you the same value four ways:

    • string - the raw line as text
    • int - the line parsed as an integer, when that makes sense
    • float - the line parsed as a float
    • count - how many lines were available in total

    The last output is the quiet hero. You get the selected line and the size of the list, so a downstream node can check "did I even ask for a valid index?" without a second count node.

    Like its sibling String Lines Count, it has no_strip and keep_empty_lines toggles that decide whether whitespace-only lines exist for indexing purposes, and a concat_method with concat / product options. Leave concat alone unless you're deliberately working with the pack's product-combination mode. The product_concat_delimiter and product_order fields only matter in that mode, so a beginner can ignore them entirely.

    The genuinely useful bit: int and float outputs

    Here's where this node earns its place. Because it parses the line for you, a multiline list can double as a tiny configuration table. Put

    512
    640
    768
    

    in a text box, feed it in, set index to 1, and the int output is a real 640 - wire it straight into a width input. No manual YogurtStringToValue conversion, no stale values you have to retype. This makes it a neat poor-man's config store for batch jobs: one box, many numbers, selected by index.

    Installing it

    Part of the Yogurt Nodes pack - one install covers all of them. ComfyUI Manager (search "ComfyUI-YogurtNodes") or:

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

    Restart, look under YogurtNodes/String. Pure Python, no models, no keys.

    Where people get burned

    Out-of-range index. Ask for line 4 when the list has 3 lines and behavior gets undefined-ish - the pack doesn't promise what you get, so guard it: wire count into a comparison before letting the index drive anything important. Also remember index is zero-based, same as Python. If the node returns the second line when you think you asked for the first, that's it, that's the bug, and everyone hits it once.

    CategoryYogurtNodes/String

    Inputs (14)

    NameTypeDefaultDescription
    no_stripBOOLEANfalse
    keep_empty_linesBOOLEANfalse
    indexINT0
    concat_methodCOMBOconcat2 options: concat, product
    product_concat_delimiterSTRING
    product_orderSTRING0,1,2,3,4,5,6,7
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING
    text5optSTRING
    text6optSTRING
    text7optSTRING
    text8optSTRING

    Outputs (4)

    NameTypeDescription
    stringSTRING
    intINT
    floatFLOAT
    countINT