EBU PromptHelper Replace
Find-and-replace for your prompt, with a case switch
- updated_prompt_text
Replace is the pack's plumbing: a straightforward find-and-replace for prompt text, with a case_sensitive toggle and the ability to match several target words at once. It looks boring next to the palette generator, but it's the node that makes the others compose. In the pack's example workflow it's doing the quiet jobs - swapping a [QUALITIES] block in, turning newlines into commas, and injecting the current datetime where a MY_NOW token sits. If Randomize is the slot machine, Replace is the clerk who files the winnings into the right form.
How it works
The mechanism is simple string replacement, with one genuinely useful feature: word_to_replace accepts multiple targets separated by |. Put person|man|woman in there and every occurrence of all three gets swapped for replace_with. When case_sensitive is on it's a literal str.replace() per target; when it's off, each word becomes a case-insensitive regex (properly escaped, so | in the target won't break the pattern). Every occurrence is replaced, not just the first one - worth knowing if your placeholder token appears twice in a prompt and you want both swapped. If word_to_replace is empty, the prompt passes through unchanged.
The inputs and output
- prompt_text - the text to modify (multiline).
- word_to_replace - the target(s),
|-separated for multiples. - replace_with - the replacement text (multiline, so you can replace a single word with a whole sentence or even a paragraph).
- case_sensitive - default true; flip off to catch
MY_TOKENwhen your prompt hasmy_token.
Output: a single updated_prompt_text STRING. There's no "replacements made" count or any other output - it's a one-in, one-out text transformer.
Where it fits
Three patterns cover most of its use. (1) Token injection: put MY_NOW, MY_WEATHER, or MY_WHEN in a prompt, and use Replace to fill it with the output of the pack's Current DateTime or Season Weather Time-Of-Day nodes - that's exactly how the example Flux workflow makes a "today's weather at the current time" style prompt. (2) Formatting: swap newlines for , to turn a List Sampler's numbered multiline output into a single-line tag block. (3) Template cleanup: replace a [QUALITIES] marker with the sampled traits you want in this run. It's also the right tool when Randomize's random pick isn't what you want - sometimes you just want a deterministic swap driven by another node's output.
Install
Part of EBU PromptHelper. ComfyUI Manager: search "EBU PromptHelper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/burnsbert/ComfyUI-EBU-PromptHelper
then restart ComfyUI. No models, no extra dependencies - this pack is Python standard library only.
Troubleshooting
The gotcha most people hit is assuming case-insensitivity: the default is case-sensitive, so MY_NOW and my_now are different strings until you flip the toggle. Also remember the | splitter - if your actual target contains a literal pipe character, it'll be treated as a separator instead. And because it replaces all occurrences, a short common word like a or the in word_to_replace will chew through your whole prompt; keep targets specific. None of these are crashes - the node can't really fail, it just faithfully does what you asked, which is usually the bug.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt_text | STRING | — | |
| word_to_replace | STRING | — | |
| replace_with | STRING | — | |
| case_sensitive | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| updated_prompt_text | STRING | — |