Nodes/ComfyUI - NeoGriever/NGs String - String Squisher
ComfyUI Node

NGs String - String Squisher

Wrap long text into fixed-width lines without losing any of it

By NeoGriever·Created 2 years ago·Updated 2 years ago· 2
NGs String - String Squisher
    • formatted_text
    • lines
    text
    maxlength20
    linebreakLF
    custom_break;

    Worth contrasting directly with this pack's NGs String Cutter: that one truncates - it throws away whatever doesn't fit within a length limit. This one reflows instead. Feed it a long block of text and a max line length, and it wraps the whole thing into multiple lines that each stay under that length, without dropping a single character. The README's one-liner: "Easy handling of logical line breaks within text."

    How it works

    It chops text into chunks no longer than maxlength, then joins those chunks back together using whichever separator linebreak specifies: LF for a normal newline, TAB for a tab character, or custom to use your own string via custom_break. You get two outputs from the same operation - the whole thing rejoined into one string (formatted_text), and the individual lines as a separate list (lines) so you can loop over them one at a time downstream - feeding each line into a per-line process, another TextBox, or a Discord post, rather than parsing the joined string back apart yourself.

    The inputs and outputs that matter

    • text - the source string.
    • maxlength - default 20, range 2–256, the per-line cap.
    • linebreak - enum (custom / LF / TAB), default LF.
    • custom_break (optional, default ;) - only used when linebreak is set to custom.

    Outputs: formatted_text (STRING, the rejoined whole) and lines (STRING, a list - one entry per wrapped line).

    Getting both a joined string and a list out of one node call is the actual convenience here - without it, you'd wrap text one way for display (joined, human-readable) and need to re-split it a second way for anything that processes line by line (feeding each caption variant to a separate node, posting one line at a time). This node does the wrapping once and hands you both shapes of the result, so you're not maintaining two slightly different wrapping passes that could drift out of sync with each other.

    How to install it

    ComfyUI Manager: search "NeoGriever," install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/NeoGriever/ComfyUI-NeoGriever
    

    then restart. No dependencies, no downloads.

    Common issues & troubleshooting

    Changed custom_break and nothing happened. linebreak defaults to LF, so custom_break sits unused unless you explicitly switch the mode to custom - setting the custom string alone doesn't activate it.

    Downstream node expects a single string, not a list. lines is a list output by design - make sure whatever consumes it is actually built to iterate over a list (a For Loop, a batch-aware node) rather than expecting one plain STRING, or route formatted_text instead if you just want everything back as one block.

    Lots of short lines for a small maxlength. With the default maxlength of 20, a genuinely long paragraph produces a lot of lines - bump maxlength up if you're wrapping prose rather than short labels or tags.

    CategoryNeoGriever/Text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    maxlengthINT202–256
    linebreakCOMBOLF3 options: custom, LF, TAB
    custom_breakoptSTRING;

    Outputs (2)

    NameTypeDescription
    formatted_textSTRING
    linesSTRING