Nodes/ComfyUI-ZhiHui/🎨 智绘_去除空行
ComfyUI Node

🎨 智绘_去除空行

The three-line text cleaner that quietly fixes your prompts

By zhuyungen·Created 8 months ago·Updated 3 months ago· 0
🎨 智绘_去除空行
    • cleaned_text
    text

    This is the most boring node in ComfyUI-ZhiHui, and I mean that as a compliment. ZH_RemoveEmptyLines ("🎨 智绘_去除空行") takes multiline text, drops every line that's blank or whitespace-only, and hands the rest back with the line breaks intact. One input, one output, zero mystery.

    You reach for it in exactly two situations. The first: text pulled from an API or a copied prompt block arrives full of stray blank lines, and you want it clean before a text node or a prompt generator touches it. The second, sneakier one: before feeding text into a splitter. Blank lines create empty fragments when you split on newlines, and empty fragments upstream of a batch loop can spawn garbage downstream - clean first, split second, and your pipeline stops tripping over nothing.

    It's part of the same Chinese-language utility pack as the rest of these nodes. In a pack that includes PSD writers, timeline editors, and memory managers, this one is the humble but honest utility - and its whole behavior is small enough to verify by reading the source.

    How it works

    Split on newlines, keep only lines where .strip() is non-empty, rejoin with \n. That's it. The one detail worth knowing: it's not just removing empty strings - lines made only of spaces or tabs count as empty too, which is the correct definition for "blank line" in practice. Lines with any visible character survive untouched, and non-blank lines keep their original content byte-for-byte.

    The inputs and outputs that matter

    • text - multiline string input.

    The single output is cleaned_text - the same string minus the blank lines. Wire it into a CLIP Text Encode, a prompt preset, or the pack's ZH_TextSplitByDelimiter before splitting.

    Install

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

    Restart ComfyUI. No models, no dependencies beyond the pack's base torch/numpy/Pillow - a node this small doesn't even need those at runtime, but the pack installs them anyway. ComfyUI Manager search "ComfyUI-ZhiHui" also works.

    Where people get burned

    Honestly, there's not much to burn yourself on. A couple of things worth saying anyway: this node does not collapse multiple blank lines into one between non-empty content in the sense of changing indentation - it only removes lines that are entirely empty, so leading/trailing whitespace inside a content line survives. If you also want that collapsed, the pack's random-prompt nodes have a "去格式" option that normalizes whitespace, but for plain blank-line removal this is the tool. And one workflow note: if you're cleaning text that downstream will treat as a single string, remember this only affects newlines - a prompt with a blank line in the middle of a sentence isn't this node's problem, that's a data issue.

    Category智绘灵箱/文本

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    cleaned_textSTRING