Nodes/ComfyUI-JNodes/Separate String By Delimiters
ComfyUI Node

Separate String By Delimiters

Split one string into four pieces at three markers

By JaredTherriault·Created 3 years ago·Updated about a month ago· 91
Separate String By Delimiters
    • string_all
    • string_a
    • string_b
    • string_c
    input_string
    delimiter_a
    delimiter_b
    delimiter_c

    The node's own description is refreshingly blunt about what it does: it "processes a multiline string and separates it into four different strings based on the given delimiters." Give it one block of text and three marker strings, and it hands back four outputs - the segments the three delimiters cut it into, plus the whole original for reference. It's the tool for a text block that's structured but not in a format any parser already understands - something you wrote yourself with clear section breaks, rather than JSON or the pack's own <params:...> tag syntax (which has dedicated nodes already).

    A realistic use: a single multiline note field where you've separated a positive prompt, a negative prompt, and a notes section with your own custom markers - ###NEG###, ###NOTES###, whatever you picked - and you want each section split out into its own wire without hand-rolling string logic.

    How it works

    input_string is the text to split. delimiter_a, delimiter_b, and delimiter_c are the three marker strings the node looks for, applied in order, cutting the input into segments at each. string_all returns the untouched original input, useful for comparison or for a downstream node that wants the whole thing alongside the pieces. string_a, string_b, and string_c are the resulting segments.

    If your delimiters don't all appear in the text - say you only ever use delimiter_a, and leave delimiter_b and delimiter_c as strings that never occur - you'll effectively only get a real split at the one marker that's actually present; the segments tied to markers that don't occur in the text won't have meaningful content to isolate. Test the exact split behavior against your own text before building a large workflow around it.

    The inputs and outputs

    • input_string (STRING) - the text to split.
    • delimiter_a, delimiter_b, delimiter_c (STRING) - the three markers to split on, in order.
    • string_all output - the original, unsplit input.
    • string_a, string_b, string_c output - the resulting segments.

    How to install it

    Via ComfyUI Manager: Install Custom Nodes, search "JNodes", install, restart. Or by hand:

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

    then restart ComfyUI. No model downloads.

    Common issues & troubleshooting

    A delimiter that doesn't appear in the text at all. If one of your three markers never occurs in input_string, don't expect that output to contain a sensible independent segment - verify the actual split behavior against a short test string first rather than assuming all three outputs are always meaningfully populated.

    Delimiter text accidentally showing up inside your prompt content. If your marker is something generic like - or a single common word, it can match somewhere you didn't intend, inside your actual description rather than at your deliberate section break. Pick delimiters that are distinctive and unlikely to occur naturally in the prose around them - something like ###SECTION### rather than a plain punctuation mark.

    Only need one split point, not three. If you're just dividing text in half at a single marker, this node is more machinery than you need - a simpler string-split approach (or just using one delimiter and ignoring string_b/string_c) gets you there without three fields to fill in.

    Whitespace or newlines around a delimiter throwing off the split. Since this operates on a multiline string, a marker that's supposed to sit cleanly on its own line but actually has trailing spaces can fail to match exactly. Keep your delimiters and the text around them consistent, or trim with JNodes_TrimAndStrip beforehand if you're not sure.

    Categorysd

    Inputs (4)

    NameTypeDefaultDescription
    input_stringSTRING
    delimiter_aSTRING
    delimiter_bSTRING
    delimiter_cSTRING

    Outputs (4)

    NameTypeDescription
    string_allSTRING
    string_aSTRING
    string_bSTRING
    string_cSTRING