Nodes/ComfyUI_NYJY/SplitString(NYJY)
ComfyUI Node

SplitString(NYJY)

Chop a text blob into a list of strings

By aidenli·Created 2 years ago·Updated 4 months ago· 146
SplitString(NYJY)
    • result
    input
    separator
    regexfalse

    Automation workflows live and die on turning one big text blob into many smaller ones. SplitString is the node that does that in ComfyUI_NYJY: give it a string and a separator, and it returns a list of strings - the input you need for anything that wants to iterate over a batch of prompts, tags, or values.

    It's from the logic corner of ComfyUI_NYJY, aidenli's utility pack (the same one that wraps the Volcengine/ByteDance APIs and ships JoyTag). These logic nodes rarely get talked about, but they're what make a "load a text file of 50 prompts and generate all of them" workflow possible. This is the node that splits the file.

    How it works. Three inputs: input (the multiline string to split), separator (what to split on), and a regex boolean. Feed it a,b,c with separator , and you get a list [a, b, c]. Under the hood it's plain Python: input.split(separator), or re.split() when regex is on. Two behaviors are worth internalizing:

    • Empty separator = no split. If separator is left blank, the node gives up on splitting and returns your input as a single-element list. It won't guess, and it won't split on whitespace for you.
    • It cleans as it goes. Every piece gets whitespace-trimmed and empty lines are dropped. So splitting a newline-separated prompt file on \n won't leave you with a pile of empty strings cluttering the list.

    Where people get burned. The classic mistake is the newline separator. A multiline field in ComfyUI may not be what you think it is - if you're splitting a text file's lines, split on \n (or \r\n if the file came from Windows; the pack's own ReadFileToString reads UTF-8 text and will hand you those \r characters to deal with). The other gotcha is regex mode: the moment you flip it on, your separator is a regular expression, so a harmless , is fine but a . matches everything instead of a literal dot. Escape your literals or leave regex off unless you actually need it.

    The output. result is typed as a STRING list - that's the "list" side of a list input. You can wire it into any node that accepts a list of strings, or feed individual items through a list-indexing node. That's the whole value: it converts freeform text into something batchable.

    Install. It comes with the whole pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aidenli/ComfyUI_NYJY
    

    restart, then pip install -r requirements.txt (or ComfyUI Manager → "Install via Git URL" → https://github.com/aidenli/ComfyUI_NYJY). This node itself needs no dependencies - the pack's requirements are heavy only because of its captioning/translation nodes.

    When to reach for it. Any time a workflow needs to go from "one string" to "many strings" - batches of prompts, comma-separated tags, newline lists from a file. It's boring, it's tiny, and it quietly makes the batch workflows possible.

    CategoryNYJY/logic

    Inputs (3)

    NameTypeDefaultDescription
    inputSTRING
    separatorSTRING
    regexBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    resultSTRING