🧹 Prompt Cleanup 🧹
The last-mile tidy-up node for messy dynamic prompts
- STRING
Chain enough Adaptive Prompts nodes together - generators, splitters, mixers, replacers - and you'll inevitably end up with double commas, stray leading whitespace, orphaned brackets, and leftover <lora:...> tags that should've been stripped earlier in the pipeline. PromptCleanup is the swiss-army node you drop right before your text encoder to sweep all of that up in one pass, so what actually reaches CLIP (or whatever encoder you're using) is clean.
How it works
Five independent toggles, each doing exactly one small job:
cleanup_commasremoves extra commas when there's no actual tag sitting between them (red,, blue→red, blue).cleanup_whitespacestrips leading/trailing whitespace first, then collapses runs of internal whitespace down to single spaces.remove_lora_tagsdeletes any<lora:...>tags still present in the string entirely.cleanup_newlines(false / space / comma) replaces\ncharacters with either nothing, a space, or a comma - useful if upstream nodes built your text with newline-separated sections that need flattening before a text encoder sees them.fix_brackets(false / (parenthesis) / [brackets] / ([both])) removes stray, unpaired brackets or parentheses that survived earlier processing - it only cleans up unpaired ones, it doesn't attempt to repair a genuinely malformed weight expression.
The inputs and outputs that matter
string- the text to clean.cleanup_commas,cleanup_whitespace- both default on.remove_lora_tags- default off; turn it on explicitly if you want LoRA tags stripped here.cleanup_newlines- false, space, or comma.fix_brackets- false, (parenthesis), [brackets], or ([both]).- Output: a single
STRING.
How to install it
Comes with the rest of the pack. Search comfyui-adaptiveprompts in ComfyUI Manager, or clone directly:
cd ComfyUI/custom_nodes
git clone https://github.com/Alectriciti/comfyui-adaptiveprompts
Restart ComfyUI. No models, no extra dependencies.
Common issues & troubleshooting
LoRA tags are still in the final text. remove_lora_tags defaults to off - if you're building a graph where LoRAs get loaded elsewhere and you want a clean text-only prompt going into CLIP, you have to switch this on explicitly rather than assuming a general cleanup catches it.
fix_brackets didn't fix a weird-looking parenthetical. It only removes brackets/parens that are genuinely unpaired - a stray leftover ( with no matching ). It won't touch something that already parses as balanced-but-odd, like (word:1.3). And worth knowing if you're spending effort preserving that syntax at all: attention-weight expressions like (word:1.3) do real work on CLIP-token models (SD 1.5, SDXL, Illustrious-lineage checkpoints), but they're silently discarded on LLM-encoded models like Z-Image or Flux 2 Klein - the tokenizer there just sees literal punctuation, which is worse than deleting it. Know which family your checkpoint belongs to before deciding whether this syntax is worth cleaning carefully or stripping outright.
Newlines are turning into odd punctuation. Double-check cleanup_newlines is set to what you actually want - false leaves raw \n characters in the string, which most text encoders handle poorly; space or comma are the safer choices for prompt text headed straight into a CLIP Text Encode node.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| cleanup_commas | BOOLEAN | true | cleans up extra commas if there is no tag present between them |
| cleanup_whitespace | BOOLEAN | true | cleans up leading/trailing whitespace, then excessive whitespace |
| remove_lora_tags | BOOLEAN | false | completely removes lora tags from the string |
| cleanup_newlines | COMBO | false | replaces newlines (\n) with a space or comma |
| fix_brackets | COMBO | ([both]) | removes stray, unpaired brackets/parentheses |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |