Prompt Cleaner
Strip the words you're sick of seeing out of every prompt
- STRING
PromptCleaner is a text-scrubbing node: you give it a prompt and a comma-separated list of words, and it removes every occurrence of those words from the text, case-insensitively. One STRING in, one STRING out. That's the whole contract, and it's genuinely useful the moment you're processing prompts in bulk.
Think about how much of prompt-batch work is copy-paste cleanup: you've got a folder of captions or generated prompts full of "masterpiece, best quality" boilerplate you want gone, or you're running a dataset through an encoder and need to strip a category word you're testing against. This node sits between a text source and your text encoder and does that filtering for you, every queue, no manual edits.
How it works
Simple and predictable. It splits your words_to_remove on commas, lowercases each one, then tokenizes the input text into words and punctuation with a regex, dropping any word that matches the removal list. Punctuation is preserved, so the surrounding structure of the prompt survives. It logs before/after to the console, which is a nice touch for verifying it did what you expected.
A couple of behavioral details worth knowing:
- Matching is case-insensitive and matches whole words only - removing "man" won't touch "woman" or "manhood."
- It's literal text filtering, not "smart" cleanup. It doesn't understand that removing "blue" changes the meaning of "blue sky" - that's on you.
- Multi-word phrases are handled as separate words; to remove a phrase like "no humans" you'd list
no, humansand accept both go, or use PromptSwap which supports quoted phrases.
The inputs that matter
- text - the prompt (multiline). Usually wired from a text loader or wildcard node.
- words_to_remove - comma-separated list, default
man, woman, world. Replace it with whatever you're actually scrubbing.
Output: one STRING - the cleaned prompt, ready for a CLIP Text Encode or your prompt-processing chain.
Installing it
Part of DJZ-Nodes. ComfyUI Manager → Install Custom Nodes → search DJZ-Nodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/DJZ-Nodes
cd DJZ-Nodes
pip install -r requirements.txt
Pure stdlib (just re and logging) - none of the pack's heavier dependencies are involved. Install the pack, use the node.
Common issues
The traps are all about expectations. First, it removes the word everywhere, including in the middle of otherwise-fine phrases - removing "old" from "an old man" leaves "an man," so check the output. Second, it only removes, never cleans up doubled spaces or grammatical debris (you'll see an man style gaps); chain it before something that doesn't care about grammar, or accept slightly untidy text. Third, if you're scrubbing words that also appear inside other words, the whole-word matching protects you - but remember it's whole-word, so a plural like "men" won't be caught by removing "man." For swapping rather than deleting, PromptSwap is the sibling node you want.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| words_to_remove | STRING | man, woman, world | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |