Nodes/ComfyUI-SA-Nodes-QQ/Prompt Replacer (QQ)
ComfyUI Node

Prompt Replacer (QQ)

Type `wordx` in your prompt, roll one line out of forty

By siraxe·Created 12 months ago·Updated 6 days ago· 74
Prompt Replacer (QQ)
    • prompt
    • selected_item
    ◄input_text►
    ◄input_list►
    ◄search_wordwordx►
    ◄seed1337►

    You've got forty lighting descriptions and one workflow. You do not want forty workflows. Prompt Replacer (QQ) is the small, unglamorous answer: you type wordx wherever the variable part of your prompt goes, paste your forty lines into the node's list, and the seed decides which one lands. Same seed, same result - which is the whole point, and the reason it beats the {a|b|c} bracket syntax a lot of us are still using.

    It's one node in siraxe's WanVideo-adjacent utility pack (sa_nodes/text), written for exactly the loop you fall into with video prompts: you're iterating on a camera move or a motion description and you want to A/B eight of them without maintaining eight graphs.

    How it works

    The node reads input_list line by line, and the syntax is worth learning because it's where the actual power is:

    • Blank lines and lines starting with # are ignored. A line that is just // toggles a block comment on or off.
    • A plain line goes into one shared pool.
    • A line prefixed with * goes into a dedicated pool for wordx; ** goes to wordx2; *** to wordx3, and so on.
    • You can prefix any line with an id@ tag - dusk@golden hour haze, long shadows. The id has to be alphanumeric and it gets validated, but honestly the code parses it and then never returns it (it builds a joined filename internally and drops it). Treat it as a label for your own sanity when the list gets long.

    At run time it scans input_text for the variants you actually used - wordx, wordx2, wordx3 - then calls random.seed(seed) and picks per variant. A variant prefers its dedicated pool; if it has none, it pulls from the shared pool without replacement, so wordx and wordx2 never get handed the same line. Two consequences worth internalizing: the shared pool is the fallback everyone draws from, and picking is fully deterministic for a given seed.

    Outputs are two strings. prompt is the rewritten text - wire it into your CLIP Text Encode, same as any other text node. selected_item is the comma-joined descriptions of what it picked. Note the node is flagged as an output node, so it's also a terminal: the pick shows up in the run's output panel, which is how you keep track of what you rolled across a batch.

    The inputs that matter

    search_word defaults to wordx, and that's a real default - change it if your prompt contains anything that starts with those five letters followed by a digit, because the detector is substring-based. Pick something you'd never type otherwise.

    input_list is the multiline box with your candidates. seed (default 1337) is what rerolls it. input_text is the odd one: it's declared single-line, so a long prompt is a horizontal-scrolling pain in the widget. The same pack ships TextMultiline - wire your prompt through that and convert input_text to an input.

    Install

    The node has no dependencies at all - the pack's requirements.txt is empty and this class only imports re and random. Easiest path is ComfyUI Manager: search the pack as ComfyUI-SA-Nodes-QQ (that's the registry display name; the repo was renamed in v1.3.4 while the URL kept the old _QQ name). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/siraxe/ComfyUI-WanVideoWrapper_QQ.git
    

    Restart, and it's under sa_nodes/text as "Prompt Replacer (QQ)". One pack-level trap while you're here: if you have a wanwrapper_qq folder in custom_nodes from before the rename, delete it. Old workflows still reference that pack id, and leaving it around is how you end up with a duplicate half-broken install instead of this one.

    Where people get burned

    Nothing happened. If neither wordx nor a numbered variant appears in the text, the node passes your prompt through untouched and returns an empty selected_item. No warning, no error. Check the spelling first.

    "Input list contains no valid entries to pick from." Every line was blank, commented, or starred. Plain unstarred lines are the shared pool, and if you only define ** and *** entries, plain wordx has nothing to fall back on and it raises.

    Same pick every queue. There's no IS_CHANGED on this node, so re-queueing identical inputs hits ComfyUI's cache and you get the identical result - change the seed, or feed it from a batch index if you want variety. And if wordx appears three times in one prompt, all three get the same replacement; it replaces every occurrence, it doesn't reroll per occurrence.

    If you already live in Impact Pack's __wildcard__ world, this isn't a replacement for that - it's the zero-setup version for one variable slot in one prompt.

    Categorysa_nodes/text

    Inputs (4)

    NameTypeDefaultDescription
    input_textSTRING—
    input_listSTRING—
    search_wordSTRINGwordx—
    seedINT13370–18446744073709550000—

    Outputs (2)

    NameTypeDescription
    promptSTRING—
    selected_itemSTRING—