Nodes/Propmt Worker/Prompt Worker
ComfyUI Node

Prompt Worker

The cleanup node the pack is named after

By lenskikh·Created 2 years ago·Updated about a year ago· 16
Prompt Worker
    • STRING
    positive
    alphabetical_sorting
    remove_lora
    lower_case
    negative_char
    blacklist

    The node the pack is named after, and the one that earns its keep. Prompt Worker is a text cleaner: you feed it a messy prompt string and it comes back deduped, optionally sorted and lowercased, with LoRA tags stripped and blacklisted words gone. Everyone has garbage in their prompt pipeline - this node exists to strip it out. It's also the only node in this pack that actually transforms a prompt rather than assembling one, so if you install just one thing from here, make it this.

    The inputs that matter

    • positive (STRING, required, forceInput) - the prompt to clean; it has to arrive on a wire, so it usually comes from a Merger or Constructor
    • alphabetical_sorting (False/True) - sort the final tags A→Z
    • remove_lora (False/True) - strip <lora:…> tags and :weight syntax
    • lower_case (False/True) - lowercase everything
    • negative_char (STRING, optional) - individual characters to delete, comma-separated
    • blacklist (STRING, optional) - words to remove, comma-separated; use word|replacement to swap instead of delete

    The output is a single cleaned STRING, deduped with order preserved and joined back with ", ".

    How it works

    It's a pipeline of regexes and string ops: dashes to spaces, dots to commas, optional weight/LoRA removal, optional lowercase, character deletion, blacklist with the | swap trick, dedupe via order-preserving dict keys, optional sort. No model, no API, no randomness - instant and deterministic. That's the good kind of node.

    Gotchas - these are real, I tested the shipped code

    1. remove_lora mangles legacy weights. The node converts dots to commas before stripping :number weights, so (blue eyes:1.3) comes out as (blue eyes, 3) - parentheses and a stray digit survive. If your workflow is full of (word:1.2) syntax, feed this node already-clean text or accept the mess. (On LLM-encoded models like Flux 2 Klein or Z-Image, that weight syntax is dead weight anyway.)
    2. Blacklist matching is case-sensitive against your prompt, even though the list itself gets lowercased. Turn on lower_case, or write your blacklist in the exact case your prompt uses - otherwise "Bad" never matches "bad".
    3. The "dash disables a token" trick in the README is dead. It promises that putting a dash in a token temporarily disables it. In the current code, every dash gets converted to a space before the skip-check runs, so the token survives - just hyphenated ("bar-baz" becomes "bar baz"). Don't rely on it.
    4. The output always ends with a trailing comma. Harmless to the encoder, mildly annoying to read. The Merger node does the same, so it's clearly the author's house style.

    Where it fits

    The canonical flow in this pack: Сonstructor (style) ← Clothes + Body, then Merger (stitch), then Prompt Worker (clean), then Clip and Text -> Encode, then the sampler. When you're merging four text sources, this is the node that stops duplicate tags and garbage tokens from reaching the encoder - which, on a strict-adherence model like Anima, is the difference between a clean render and body horror.

    Install

    Pack-wide, dependency-free, no models:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lenskikh/ComfyUI-Prompt-Worker
    

    Restart ComfyUI, or use ComfyUI Manager and search "Prompt Worker" (the registry title is misspelled "Propmt Worker", so try both spellings). The only failure mode worth knowing: it reads no external config, so the only way to break it is to feed it a broken input - and even then it degrades to a loud-ish string, not a crash.

    CategoryPrompt Worker

    Inputs (6)

    NameTypeDefaultDescription
    positiveSTRING
    alphabetical_sortingCOMBO2 options: False, True
    remove_loraCOMBO2 options: False, True
    lower_caseCOMBO2 options: False, True
    negative_charoptSTRING
    blacklistoptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING