Sentence Filter ✂️
Every sentence in your prompt, on a leash
- text
- sentences_deleted
- sentences_replaced
You know the workflow you grabbed from a friend where every generation comes out with a sentence you didn't ask for - a www.example.com watermark shout-out, a baked-in LoRA tag, a template caption that no longer applies? Sentence Filter is the node that scrubs those out for you automatically. It's a text-in, text-out utility: feed it a string from anywhere in your graph, and it deletes whole sentences containing trigger words you list, or rewrites them into a replacement sentence, then hands the cleaned text to whatever comes next.
It's a boring node, and that's the compliment. No model files, no API keys, no VRAM, no dependencies beyond Python's standard library. ComfyUI's whole selling point is that you can rewire the graph - and text utilities are the glue that makes the rewiring usable. This one is a cheap, zero-friction example of that: string in, string out, nothing else touched.
The mechanism
The node splits your text into sentences at periods and walks through them one by one. Two filters run per sentence:
- Delete - if the sentence contains all the words in
delete_words, the whole sentence is dropped. - Replace - if it contains all the words in
replace_words, it's swapped forreplacement_sentence.
Deletion wins if a sentence matches both. Matching is case-insensitive by default (flip case_sensitive if you need exact), and it's substring matching, not word boundaries - so blonde also catches blonde-haired. A couple of thoughtful touches: dots inside URLs are protected before splitting so www.example.com doesn't become three "sentences", and a replaced sentence always gets a period appended, so don't type your own trailing one or you'll end up with ...
Inputs & outputs
You'll actually touch four inputs and maybe glance at the counters:
text(required) - the string to filter.delete_words- comma-separated words. The trap: it's AND, not OR.blonde, straight, youngonly kills a sentence that contains all three. Missing one and the sentence survives. Want OR? Use one word at a time or chain two nodes.replace_wordsplusreplacement_sentence- for rewriting instead of deleting.case_sensitive- off by default.
Outputs are text (the cleaned string, ready to wire into a CLIPTextEncode or any other text consumer) plus sentences_deleted and sentences_replaced INTs, handy if you're batch-running and want to know how much got touched. On an empty input it short-circuits to empty output and zeroes - no error.
Install
The easy route: ComfyUI Manager, search "comfyui-sentence-filter", install, restart. Or from the terminal:
cd ComfyUI/custom_nodes/
git clone https://github.com/Slartibart23/comfyui-sentence-filter.git
Restart ComfyUI and the node appears under text › processing as "Sentence Filter ✂️". No model downloads, no pip install - the README says Python 3.13+, and beyond that it's pure standard library.
Where people get burned
- AND logic catches people every time. You list three words expecting "delete any sentence with any of these" and the node quietly keeps half your sentences. Read the trigger fields as must contain all and it makes sense.
- Sentence splitting is period-based. Only URL dots are protected. A mid-sentence period like
e.g.orFig. 2will split there, so your "sentence" boundaries aren't always what you think. - Replacement period doubling, as noted above - leave the trailing period off
replacement_sentence. - Whitespace gets tidied. Double spaces collapse and leading/trailing whitespace is trimmed on the way out. Fine for prompts, worth knowing if you're feeding the text somewhere that cares about formatting.
Is this the pack to build a workflow around? No. It's a single-purpose utility for one recurring annoyance, and it does that one thing cleanly. If you batch-generate from templates that accumulate junk sentences, or you distribute workflows and want the credits/watermarks stripped at the source, it earns its place. The author's handle is a Hitchhiker's Guide reference, which checks out for a node whose whole job is tidying up after someone else's mess.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| delete_wordsopt | STRING | — | |
| replace_wordsopt | STRING | — | |
| replacement_sentenceopt | STRING | — | |
| case_sensitiveopt | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| sentences_deleted | INT | — |
| sentences_replaced | INT | — |