🌸Flower Keyword Replacer
Ten-slot find-and-replace for prompt templates, no regex required
- text
Flower Keyword Replacer is the prompt template's duct tape: ten keyword→replacement slots, one text in, one text out, and zero AI involved. You write a prompt with placeholder tokens like *WOMAN* and *Color*, this node swaps them for concrete values, and the result goes to the CLIP encoder. If you've ever hand-edited the same prompt ten times to test ten variations, this is the node that makes that a two-second change instead.
How it works
The mechanism is exactly as unglamorous as it sounds: a sequential str.replace() for each slot, in order from slot 1 to slot 10. Empty keywords are skipped, and only non-empty keywords are replaced - so leaving most slots blank and using one or two is the normal way to run it. Output is a single text STRING ready to feed a Text Encode or another node downstream.
Two things follow from "sequential replace" that people forget:
- Order matters. Slot 1's replacement happens before slot 2 matches, so a later keyword can match text that an earlier replacement just produced. If your tokens can overlap, order them deliberately.
- It's plain literal substitution. No regex, no wildcards, no case-insensitive matching.
*color*and*Color*are different tokens. That's a feature for prompt work - you control exactly what changes - but it means you must match your placeholder spelling exactly.
The one workflow it shines in
The pack's own demo shows the intended pattern: pair it with the Flower Multiline Prompt Selector in Combination mode. The selector picks one unit from each of several wildcard files (a nationality, an age, an expression, a body type), concatenates them, and this replacer's job is to slot those picks into a fixed template. Say the selector outputs 一位青春洋溢的18歲少女,表情自然帶笑 and 駝色; a template like "*WOMAN*,穿著*Color*短版襯衫。" becomes a complete, varied prompt each run. The whole thing runs headless per batch, which is the point - variation without you retyping anything.
It's also fine as a standalone testing tool: swap one concept at a time in a fixed prompt and batch with a locked seed to isolate what each substitution actually changes. That's the closest thing this pack has to an A/B test rig.
Install
Same pack as everything else in this family:
cd ComfyUI/custom_nodes
git clone https://github.com/weichenglin0215/comfyui-flower-tools.git
Then restart. Or ComfyUI Manager → search ComfyUI Flower Tools. No models, no downloads; the pack's only real dependency (opencc) isn't even used by this node.
Gotchas
- Ten slots is the ceiling - if your template needs eleven tokens, you'll chain two of these nodes or pre-merge some replacements into a single slot.
- The
textinput is multiline, and eachreplacement_Nis multiline too, so multi-line replacements work fine. Multi-line keywords are technically possible but a terrible idea - keep keywords short and distinctive. - Because every slot runs even when empty (it just no-ops), there's no harm in leaving slots 5–10 unused. Don't feel obligated to fill all ten.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| keyword_1opt | STRING | — | |
| replacement_1opt | STRING | — | |
| keyword_2opt | STRING | — | |
| replacement_2opt | STRING | — | |
| keyword_3opt | STRING | — | |
| replacement_3opt | STRING | — | |
| keyword_4opt | STRING | — | |
| replacement_4opt | STRING | — | |
| keyword_5opt | STRING | — | |
| replacement_5opt | STRING | — | |
| keyword_6opt | STRING | — | |
| replacement_6opt | STRING | — | |
| keyword_7opt | STRING | — | |
| replacement_7opt | STRING | — | |
| keyword_8opt | STRING | — | |
| replacement_8opt | STRING | — | |
| keyword_9opt | STRING | — | |
| replacement_9opt | STRING | — | |
| keyword_10opt | STRING | — | |
| replacement_10opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |