Nodes/ComfyUI-Minitools/Sensitive Word Filter 👻
ComfyUI Node

Sensitive Word Filter 👻

Swap the words your model won't touch for ones it will, one random pick at a time

By lepiai·Created 2 years ago·Updated 13 days ago· 10
Sensitive Word Filter 👻
    • STRING
    prompt
    sensitive_words
    replacement_word_listword1,word2,word3

    Some words get your prompt bounced by a filter, flagged by a service, or just render like garbage in a specific model. The blunt fix is to rephrase them - but when you're generating in bulk and want the same intent preserved with different words every time, hand-editing doesn't scale. Sensitive Word Filter 👻 automates it: you give it a list of words to strike and a list of words to strike with, and it swaps each one for a random replacement from your pool.

    It's a tiny utility node from the ComfyUI-Minitools pack, and honestly it's the pack's simplest node - the whole thing is a few dozen lines of Python. That's fine. Sometimes the right tool is a hammer.

    The three inputs

    All three are plain text fields, all multiline:

    • prompt - the text you want cleaned.
    • sensitive_words - comma-separated list of the words to remove. The node's own example: cat,secret.
    • replacement_word_list - comma-separated pool to draw from. Default is the placeholder word1,word2,word3.

    One output: the filtered STRING.

    The author's example is the clearest description: prompt "I have a secret and it's cat", sensitive words cat,secret, replacements dog,fish → you get something like "I have a fish and it's dog". Note the random - run it twice and the mapping can differ, which is the point if you're trying to keep a batch of generations from looking identical.

    How it works

    It splits both lists on commas, then for each sensitive word it does three things:

    1. Whole-word matching. It uses \b word boundaries in a regex, so cat won't touch catalog or category. That's the one genuinely good decision in here.
    2. Random, non-repeating replacements. It tracks which replacement words it has already used so the same pick doesn't land twice in one pass - a small nicety that keeps the output from looking lazy.
    3. Graceful fallback. If either list is empty, it returns your prompt untouched instead of crashing.

    There's no model involved, no API call, nothing local to load. It's pure string manipulation, which makes it instant and free.

    Where it stumbles (the honest version)

    The source code carries the author's own TODO, and it's the thing to know: this only handles English. The comment says it outright - 不能替换中文, "can't replace Chinese". The \b word-boundary logic and the whole design are English-token-centric, so if you're feeding it Chinese or Japanese text, the replacements will silently do nothing or match unpredictably. Plan accordingly.

    Also worth noting: this is a lexical filter, not a semantic one. It swaps the words you listed and nothing else. If your "sensitive" word has synonyms you didn't enumerate, they sail through. And because the replacement is random per run, there's no determinism - set a fixed seed upstream if you need reproducible outputs for debugging.

    Install

    # ComfyUI Manager: search "ComfyUI-Minitools"
    # or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/lepiai/ComfyUI-Minitools
    # restart ComfyUI
    

    No dependencies beyond Python's built-in re and random. This is one of the lightest nodes you'll ever install.

    What it's actually for

    Realistically: scrubbing words before your prompt hits a service with a filter (the pack is aimed at the MiniMax H3 video API crowd, where a bounce wastes a paid call), or de-duplicating language in batch runs. It's not a censorship-escape tool and it doesn't pretend to be - it's a mechanical find-and-replace with a random twist. If that's the job, it does it well; if you were hoping for something smarter, this isn't it. For the 300-word niche it fills, it's perfectly serviceable.

    CategoryMiniTools

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRING
    sensitive_wordsSTRING
    replacement_word_listSTRINGword1,word2,word3

    Outputs (1)

    NameTypeDescription
    STRINGSTRING