Nodes/Nodes for use with real-time applications of ComfyUI/Multiline Text πŸ•’πŸ…‘πŸ…£πŸ…
ComfyUI Node

Multiline Text πŸ•’πŸ…‘πŸ…£πŸ…

The Tiny Text Sanitizer

By ryanontheinsideΒ·Created 2 years agoΒ·Updated about a year agoΒ· 82
Multiline Text πŸ•’πŸ…‘πŸ…£πŸ…
    • STRING
    β—„textLine 1 Line 2 Line 3β–Ί
    β—„strip_whitespacetrueβ–Ί
    β—„remove_empty_linesfalseβ–Ί

    This is the simplest node in the pack, and it knows it. Multiline Text takes a block of text, optionally strips the whitespace off every line, optionally drops the empty lines, and outputs the cleaned result as a STRING. That's the entire feature list. If you're already on board, you can stop reading and go install it - it's exactly as deep as it looks.

    Why does a real-time pack ship a text-cleaner? Because real-time workflows generate text on the fly, and generated text is filthy. A control node cycles through prompts, an LLM call or Whisper transcript drops in with trailing spaces and blank lines, and the result gets fed to a CLIP text encoder or a Text Renderer where formatting gremlins show up as garbage. Two booleans fix the common cases: strip_whitespace trims leading/trailing spaces per line (on by default), and remove_empty_lines drops lines that are empty or whitespace-only (off by default, since sometimes you want deliberate blank lines for spacing).

    Mechanically it's a five-line function - split on \n, filter with the two flags, rejoin. No state, no caching, no always_execute (it's not one of the stateful control nodes, just a plain utility in the pack's text category). It's the kind of node you don't notice until a workflow stops working and you realize the prompt had a trailing newline the whole time.

    The inputs

    • text - the multiline string box. Defaults to Line 1\nLine 2\nLine 3.
    • strip_whitespace - trim each line (default on).
    • remove_empty_lines - drop blank lines (default off).

    Output: one STRING, the processed text.

    Install & where it fits

    From ryanontheinside/ComfyUI_RealtimeNodes - ComfyUI Manager (search "Control Nodes" or "RealtimeNodes"), or:

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

    Real talk: there are a dozen free-standing "text tool" nodes in the wider ecosystem that do this and more, so you shouldn't install this pack for Multiline Text. But if the pack's already in your custom_nodes folder - because you wanted the control nodes or hand tracking - this is a perfectly serviceable inline cleaner that saves you a dependency. It pairs naturally with the pack's Text Renderer and String Sequence, and honestly, when your animated prompt is arriving with a trailing space, a node that just fixes it is worth more than its two seconds of fame.

    Categorytext

    Inputs (3)

    NameTypeDefaultDescription
    textSTRINGLine 1 Line 2 Line 3Enter text (use \n for new lines)
    strip_whitespaceBOOLEANtrueRemove leading/trailing whitespace from each line
    remove_empty_linesBOOLEANfalseRemove empty or whitespace-only lines

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”