Clean String Adv. π²
The janitor for prompts that came out of a spreadsheet
- text
Every serious ComfyUI user ends up with a prompt from somewhere ugly: a spreadsheet of Danbooru tags with stray double spaces, a caption list with trailing commas, a copy-paste from a forum post with blank lines everywhere. Clean String Adv. is the node that takes that mess and normalizes it into something a prompt encoder won't choke on. It's a string filter pipeline in a single node, and it's genuinely handy for batch workflows.
What it does
One multiline input_text in, one cleaned text out. Between those it applies up to six independent filters, each with its own control:
strip-off/left/right/both. Which sides of whitespace to trim. Defaultboth.trailing_commas-off/remove/add/add + space. Theadd + spacemode is the nice touch: it adds a comma if none exists, and adds a space after an existing comma-without-space. Defaultremove.newlines-off/remove empty/collapse lines. Collapse joins everything into one line - the classic move when you're feeding a single-line prompt encoder. Defaultoff.collapse-off/spaces/spaces + commas. Squashesapple, bananaintoapple, banana. Defaultspaces + commas.remove_duplicate_tags- a boolean that dedupes comma-separated entries, soapple, banana, apple, orangebecomesapple, banana, orange. This one is the star for anyone cleaning tag lists.case- the big one, ten options:off,lowercase,uppercase,capitalize(per-sentence),capitalize_1st_letter,camelcase,pascalcase,snakecase,kebabcase,titlecase.
The order of operations matters and is fixed: strip β trailing comma β newlines β collapse β dedupe β case. So you can, say, collapse lines and lowercase a whole batch of prompts in one pass.
Why you'd use it
Prompt hygiene is real. The prompt-engineering docs hammer on token waste: quality-tag spam and duplicate words cost you tokens you could spend on actual content, and on LLM-encoded models there's an attention cap around 75-100 effective tokens. Cleaning a tag list before it hits the encoder is free quality. It's also the right tool when you're generating filenames or metadata strings from prompts - the case modes exist for exactly that.
Inputs and output
input_text- the raw string (multiline).- Output:
text- the cleaned string.
Everything is widget-driven, no connections needed beyond the text. It's marked experimental in the code, but for string filtering there's not much to break.
Installing it
Part of the RyuuNoodles pack:
cd ComfyUI/custom_nodes
git clone https://github.com/DraconicDragon/ComfyUI-RyuuNoodles
Restart ComfyUI, or use ComfyUI Manager (search "RyuuNoodles"). No models, no extra dependencies.
Gotchas
The case transformations can surprise you on punctuation-heavy text - camelcase on a sentence with commas produces stuff like appleBananaOrange.Juice, which is fine for filenames and nonsense for prompts. And remove_duplicate_tags operates on comma-separated entries, so if your prompt is prose rather than tags, it does nothing useful. Match the filter to the input format, and you're good.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text | STRING | Text input to be cleaned. | |
| strip | COMBO | both | Control which side(s) of whitespace to strip from the input string. |
| trailing_commas | COMBO | remove | Remove or add a comma at the end of the input string. Will not add a comma if one already exists, but will add a space if 'add + space' is chosen and a comma exists but no space. |
| newlines | COMBO | off | Control how newlines are handled off = keep all lines remove empty = drop blank lines collapse lines = join all lines into one |
| collapse | COMBO | spaces + commas | Collapse multiple consecutive spaces into one, or collapse both spaces and commas into a single occurrence depending on the selected option. Example: 'apple, banana, apple, orange.' β 'apple, banana, orange.' |
| remove_duplicate_tags | BOOLEAN | false | Remove duplicate tags/words separated by commas, handling spaces around commas and ensuring only unique entries remain. Example: 'apple, banana, apple, orange' β 'apple, banana, orange' |
| case | COMBO | off | Change the case of the string. Examples with input 'apple, banana, orange.': off = no change ('apple, banana, orange. juice') lowercase = all lowercase ('apple, banana, orange. juice') uppercase = ALL UPPERCASE ('APPLE, BANANA, ORANGE. JUICE') capitalize = Capitalize the start of every sentence (after punctuation or empty lines) and lowercase the rest ('Apple, banana. Orange. Juice') capitalize_1st_letter = Capitalize only the first letter of the input string ('Apple, banana. orange. juice') camelcase = likeThisExample ('appleBananaOrange.Juice') pascalcase = LikeThisExample ('AppleBananaOrange.Juice') snakecase = like_this_example, always lowercase ('apple_banana_orange._juice') kebabcase = like-this-example, always lowercase ('apple-banana-orange.-juice') titlecase = Every Word Capitalized ('Apple, Banana, Orange. Juice') |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | β |