PD_empty_word
Collapse a text dump into clean one-line-per-item blocks
- formatted_string
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. Defaultsafetensors; set it to whatever your dump's separator is.remove_empty_lines/trim_whitespace- both defaultTrue; 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.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | — | |
| line_break_keyword | STRING | safetensors | — |
| remove_empty_linesopt | BOOLEAN | true | — |
| trim_whitespaceopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| formatted_string | STRING | — |