HB Tidy String
Prompt hygiene without the regex headache
- tidied_text
HB Tidy String is the kind of node you don't know you need until you've spent an hour staring at a prompt that looks like moon,, car,,, tree and wondering why your output has random empty spaces in it. It's a text-hygiene pass for prompt strings: give it messy text, get back the same text with the formatting crud scraped off. Two inputs, one output, zero learning curve.
What it cleans
Drop in a text (STRING, multiline) and it runs a fixed pipeline of regex passes straight out of the source:
- newlines collapse into
,- multi-line text becomes one comma-joined line - runs of commas (
,,,) become one comma - spaces before commas get removed
- multiple spaces collapse to one
- empty quotes
""and the wildcard-artifact"_"get dropped - lone
!,?, and"sitting on their own (surrounded by whitespace, not attached to a word) get stripped - leading/trailing commas and whitespace get trimmed
There's also a tidy_enabled dropdown (enable / disable) so you can bypass the whole thing without rewiring your graph - handy when you're debugging whether it's the cleaner or the model that mangled something. The output is tidied_text.
The honest limits
This node fixes formatting, not content. "clean prompot" stays "clean prompot" - it has no idea that's a typo, and it won't fix spelling or reorder a garbage tag list. It also doesn't deduplicate words, only commas. One quirk worth knowing: the quote-stripping pass only removes exact "" and "_", so a genuinely quoted phrase like "blue sky" keeps its quotes. And it will happily eat a standalone ! or ? - if you prompt dramatic!! attached to a word, that survives, but a lone ! on its own line is gone. For SD-style comma-tag prompting that's almost always what you want; just don't expect it to respect emphasis.
Why you'd reach for it
Three real uses. First, after a wildcard pipeline - when your processor joins selected lines with commas and appends extras, this is the cleanup stage. Second, after any LLM-generated or spreadsheet-pasted text, which loves to arrive with stray newlines and doubled punctuation. Third, as a normalization step in a reusable workflow so every prompt hits the CLIP encoder in the same shape regardless of where it came from. It pairs naturally with the wildcard node in the same pack, but it's genuinely pack-agnostic - it works on any string, from anywhere.
Install
Part of HB ComfyUI Nodes (HassanEclipse/comfyui-hb-party). Via ComfyUI Manager:
Manager → Install via Git URL → https://github.com/HassanEclipse/comfyui-hb-party
or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/HassanEclipse/comfyui-hb-party comfyui_HB_Party
Restart, done. The pack has no Python dependencies and downloads no models - one of those rare installs where nothing can break because there's nothing to install. (Fun detail: it still carries the JN_Party category from the pack's earlier life as the JN node family - a rebrand that's cosmetic, not functional.)
Bottom line
It's a small utility, and it knows it. But if you build prompt pipelines where text accumulates junk, dropping a single tidy node before the encode step will quietly save you more debugging time than you'd expect from a handful of regex passes.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| tidy_enabled | COMBO | 2 options: enable, disable |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| tidied_text | STRING | — |