Nodes/Comfyui_PDuse/PD_empty_word
ComfyUI Node

PD_empty_word

Collapse a text dump into clean one-line-per-item blocks

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PD_empty_word
    • formatted_string
    input_string
    line_break_keywordsafetensors
    remove_empty_linestrue
    trim_whitespacetrue

    PD_empty_word (PD_empty_word) reformats a messy text block: it collapses all whitespace into single spaces, trims the ends, then inserts a line break after every occurrence of a keyword you choose. The tell is the default keyword - safetensors - which makes it obvious what the author built this for: taming the one-line-everything dumps that fall out of model-metadata readers and file scanners, where you end up with a wall of words and need each model name on its own line.

    How it works

    Three passes, in order. First it replaces every run of whitespace - newlines, tabs, multiple spaces - with a single space, so your multi-line garbage becomes one long line. Then it trims leading/trailing whitespace (toggleable via trim_whitespace). Then, if a line_break_keyword is set, it inserts a newline after each occurrence of that keyword. The remove_empty_lines option cleans up blank lines that result. The keyword matching is exact and uses the literal string, so safetensors splits the dump after every file named .safetensors - giving you exactly one line per model.

    If you leave the keyword empty, it just does the whitespace collapse and trim, which on its own is a handy "make this paste usable" step.

    The inputs that matter

    • input_string - the messy text (multiline, wireable).
    • line_break_keyword - what to break lines after. Default safetensors; set it to whatever your dump's separator is.
    • remove_empty_lines / trim_whitespace - both default True; leave them that way unless you specifically want the raw spacing.

    Output is a single formatted_string.

    Installing

    Part of the 7BEII/Comfyui_PDuse pack. ComfyUI Manager → search "Comfyui_PDuse" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/7BEII/Comfyui_PDuse
    cd Comfyui_PDuse
    pip install -r requirements.txt
    

    Restart after. No models, no extra dependencies.

    Gotchas

    The keyword match is literal and case-sensitive - safetensors won't catch Safetensors. And because it breaks lines after the keyword, you'll get model.safetensors\n with the newline following the match, not before it; if you need the break on the other side, pick a keyword that makes that work. The whitespace collapse is aggressive too - it's the point, but don't feed it text where line structure itself is meaningful (code, JSON) unless you want it flattened first.

    CategoryPDuse/Text

    Inputs (4)

    NameTypeDefaultDescription
    input_stringSTRING
    line_break_keywordSTRINGsafetensors
    remove_empty_linesoptBOOLEANtrue
    trim_whitespaceoptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    formatted_stringSTRING