ComfyUI Node

TextSplit

Cut a string in half on a separator

By chibiace·Created 3 years ago·Updated 9 months ago· 92
TextSplit
    • text
    text
    separator.
    reverse
    return_half

    TextSplit does one narrow thing: it breaks a string apart wherever a separator character shows up, and hands you back either the first half or the second half. It's not a general string-manipulation node - there's no join, no trim, no regex - just a clean way to lop off part of a longer piece of text without writing a custom node yourself.

    The obvious use is trimming an over-long prompt or a caption. Say you've got a block of text from an LLM captioner or a wildcard-generated description and you only want the first sentence or two for your positive prompt - feed it through TextSplit with separator set to . and return_half set to "First Half," and you get everything up to roughly the middle occurrence of the period, cut clean.

    How it works

    Near as I can tell from the schema - there's no tooltip spelling out the exact algorithm - TextSplit finds every place separator occurs in your text, splits the string into pieces at those points, and stitches either the first half or the second half of those pieces back into one string. That means it's splitting on occurrences of the separator, not on the literal character-count midpoint of the string. A separator that appears zero or once will behave more like a coin flip than a clean cut, so it's most predictable on text with several repeats of your chosen separator - periods in a multi-sentence caption, commas in a tag list.

    The inputs and outputs that matter

    • text - the string you're splitting.
    • separator - what to split on, defaulting to .. Any string works, not just single characters - you could split on , for a comma-tag list, or on a custom delimiter you control yourself.
    • reverse - a toggle; flip it if the half you're getting back is consistently the wrong one for a given return_half setting. Treat it as "try both and see" rather than something to reason out in advance.
    • return_half - "First Half" or "Second Half," which piece you want returned.

    The single output is text, a STRING, ready to feed into a CLIPTextEncode, a Textbox, or any other Chibi text node.

    How to install it

    • ComfyUI Manager: search "ComfyUI-Chibi-Nodes", install, restart.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chibiace/ComfyUI-Chibi-Nodes/, restart.

    Pure logic, no models, no dependencies beyond ComfyUI itself. It lands under Chibi-Nodes/Text in the add-node menu once installed. The pack overall is a small personal grab-bag of utility nodes - the README itself calls them "experimental" and notes version 2 shipped "with more bugs" - so treat something this specific as exactly what it looks like: a tool built to scratch one particular itch, not a polished, broadly-tested string library.

    Common issues

    The most common surprise is getting a half that doesn't match your expectation - because the split happens at separator occurrences rather than the string's literal midpoint, "First Half" of a three-sentence caption split on . isn't guaranteed to be exactly 1.5 sentences. If the output looks off, first check how many times your separator actually appears in the text; with only one occurrence you're really just choosing "before the separator" or "after it," which is a much blunter tool than it sounds. If that's not what you want, flip reverse and compare, or pick a separator that appears more consistently in your input.

    CategoryChibi-Nodes/Text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    separatorSTRING.
    reverseCOMBO2 options: false, true
    return_halfCOMBO2 options: First Half, Second Half

    Outputs (1)

    NameTypeDescription
    textSTRING