Nodes/PromptModels Studio/🛡️ Text Prompt Blocker
ComfyUI Node

🛡️ Text Prompt Blocker

The guardrail that fails loud on purpose

By cdanielp·Created 9 months ago·Updated 2 months ago· 28
🛡️ Text Prompt Blocker
    • allowed_output
    • is_blocked
    • matched_word
    prompt
    blocked_wordschild, kid, baby, infant, underage, young, school, nursery, teen, minor, toddler, preteen
    case_sensitivefalse
    hard_blocktrue
    detect_containedtrue
    expand_variationstrue

    A text-safety node you'd actually put in front of a pipeline. It takes a prompt, checks it against a blocklist, and then - this is the part people don't expect - it has two very different failure modes you choose from. In its default hard_block mode it raises an exception if it finds a banned word, stopping the workflow dead with a clear "PROMPT BLOQUEADO - Palabra detectada" error. In soft mode it returns an empty string instead, so the rest of the graph keeps running on nothing. Fail loud, or fail soft: your call.

    Where does this belong? It's the kind of node you put in front of anything that sends prompts to third parties or runs in an automated loop - a batch renderer, a queue, a workflow shared with others. The default blocklist is telling: child, kid, baby, infant, underage, young, school, nursery, teen, minor, toddler, preteen. This is a content-safety guardrail aimed at preventing your pipeline from generating material involving minors, and the default list is a real, opinionated choice. You can replace it with your own words entirely.

    How the detection works

    Three switches control the matching, and the defaults are aggressive:

    • detect_contained (default on) - substring matching: "childish" triggers on "child". Off means exact word-boundary matching only.
    • expand_variations (default on) - auto-expands each blocked word into known variants (children, childhood, kids, kiddo…) plus common suffixes (s, es, ish, like, hood, ness). This is why the default list punches far above its literal weight.
    • case_sensitive (default off) - case-insensitive by default.

    The inputs and outputs

    • prompt - the text to check.
    • blocked_words - comma-separated list (the defaults above).
    • hard_block - true = raise on match; false = output empty string.
    • The other three toggles as described.

    Outputs: allowed_output (STRING - the prompt if clean, empty string if soft-blocked), is_blocked (BOOLEAN), and matched_word (STRING - which word tripped it, or empty). The three together mean you can not only block but react: switch on is_blocked, inspect matched_word, log it.

    Installing it

    ComfyUI Manager → search "COMFYUI_PROMPTMODELS" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cdanielp/COMFYUI_PROMPTMODELS
    

    No API key, no model downloads - pure Python string matching. ComfyUI >= 0.26.0.

    The honest caveats

    Substring matching with detect_contained on is blunt. "Young" in "young adult fantasy" or "school" in "school of fish" will trip it, and that's by design - this node prefers false positives over false negatives. If you're filtering creative prompts, you'll spend a session tuning blocked_words and probably turning detect_contained off for words with innocent uses. And know what "soft mode" actually gives you: an empty string that flows downstream, which can quietly produce a blank-conditioning image. That's why the hard default exists - for this node, failing loud is usually the correct failure.

    CategoryText/Security

    Inputs (6)

    NameTypeDefaultDescription
    promptSTRING
    blocked_wordsSTRINGchild, kid, baby, infant, underage, young, school, nursery, teen, minor, toddler, preteen
    case_sensitiveoptBOOLEANfalse
    hard_blockoptBOOLEANtrue
    detect_containedoptBOOLEANtrue
    expand_variationsoptBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    allowed_outputSTRING
    is_blockedBOOLEAN
    matched_wordSTRING