Nodes/ComfyUI-NKD-Basic-Tools/😺NKD String Split
ComfyUI Node

😺NKD String Split

Split your LLM's list into generations

By Nekodificador·Created about a month ago·Updated 3 days ago· 71
😺NKD String Split
    • strings
    • count
    â—„textâ–º
    â—„delimiterNew Lineâ–º
    â—„custom_delimiterâ–º
    â—„trim_whitespacetrueâ–º
    â—„skip_emptytrueâ–º
    â—„remove_numberingfalseâ–º

    You pasted a block of text into ComfyUI - twenty tag sets, a numbered list your LLM just spat out, a wall of prompts separated by lines - and you want twenty generations, not one giant prompt. The manual version is splitting it yourself and building a row of text-encode nodes. 😺NKD String Split does it in one node: it splits the text into a list, and in ComfyUI a list output means downstream nodes run once per item. One run of the graph, N images. That's the entire pitch, and it's a good one.

    How it works

    You feed it text and it returns strings as a list, plus a count. The magic isn't in the splitting - it's that the node outputs a list of strings, and ComfyUI's native list mechanism fans that out: every node downstream (CLIP Text Encode, then the sampler) executes once per item. That's the same "one input item → one execution" behavior the whole batch-plumbing layer rides on, and it means no batch nodes, no loop nodes, no extra wiring between the splitter and the sampler.

    The split itself is straightforward and well-tooled. The delimiter defaults to new line, with comma, period, slash, pipe, and semicolon one dropdown away, plus a Custom option where \n and \t are understood for when your text uses something unusual. Then three cleanup toggles do the work your fingers would otherwise do:

    • Trim whitespace (on) - strips spaces and line breaks around each piece.
    • Skip empty (on) - drops pieces that end up empty.
    • Remove list numbering (off) - strips leading markers like 1., 2) or - from each piece. This is the one that makes LLM output usable, because an LLM will absolutely give you a nicely numbered list and you don't want "3. A knight" going into your prompt as a literal string.

    The inputs and outputs that matter

    Inputs: text (multiline), delimiter, custom_delimiter (when delimiter is Custom), and the three toggles above. Outputs: strings (the list - wire this into a CLIP Text Encode) and count (an INT, handy if you want to display or log how many you got).

    The classic wiring: split → 😺NKD Prompt Variables (feed the list into a variable chip) or straight into CLIP Text Encode → sampler → N images. With the pack's own Prompt Variables node, the two make a neat loop: LLM writes the variations, String Split turns them into a list, Prompt Variables slots each one into the fixed base prompt. No LLM-to-ComfyUI glue needed beyond a plain text output.

    Install

    Via ComfyUI Manager, search "NKD Basic Tools" and install, then restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools
    

    then restart. Pure text utility - no Python deps beyond what the pack ships, no models, no GPU. It does use the pack's newer extension API (comfy_api.latest), so keep ComfyUI reasonably up to date or the node won't register.

    Gotchas

    If every piece gets filtered out, the node still outputs one empty string rather than an empty list - so downstream doesn't break on zero items, but it does mean you can run a batch that silently generates "empty prompt" images if you told it to skip everything. remove_numbering only strips the leading marker from each piece; it won't clean up numbering buried mid-line. And don't forget the output is a list: if you wire it into a node that doesn't fan out lists, you'll get one run using the first item, which is a confusing way to find out your downstream node ignores the list.

    Category😺NKD Nodes/Basic

    Inputs (6)

    NameTypeDefaultDescription
    textSTRINGThe text to split.
    delimiterCOMBONew LineCharacter that separates the pieces.
    custom_delimiterSTRINGYour own separator, used when Delimiter is Custom. \n and \t are understood.
    trim_whitespaceBOOLEANtrueRemove spaces and line breaks around each piece.
    skip_emptyBOOLEANtrueDrop pieces that end up empty.
    remove_numberingBOOLEANfalseStrip leading markers like '1.', '2)' or '-' from each piece — for numbered lists written by an LLM.

    Outputs (2)

    NameTypeDescription
    stringsSTRINGOne item per piece. Downstream nodes run once per item.
    countINTHow many pieces came out.