LayerUtility: UserPrompt Generator Replace Word(Advance)
UserPrompt Generator Replace Word — ComfyUI Node Guide
- user_prompt
Find-and-replace on a prompt sounds trivial until you actually try it: swap "red dress" for "blue jacket" with a literal string replace and you often end up with grammatically broken leftovers, or the wrong word replaced somewhere the token appeared incidentally. This node is the pack's answer to that - it's explicit in the README that it's "not only a simple replacement, but also a logical sorting of the text based on the context of the prompt words to achieve the rationality of the output content." In other words, it's trying to keep the sentence coherent, not just swap tokens.
The interface is small and purpose-built. You give it orig_prompt (your starting text), exclude_word (the thing you want gone), and replace_with_word (what should take its place), and it hands back a rewritten user_prompt string. template currently only offers one option - "prompt replace word" - since this node sits in a small family of "UserPrompt Generator" nodes in the pack that share a template mechanism; this is the one specifically wired for word substitution rather than generating a prompt from scratch.
Worth being straightforward about what's not documented: the README doesn't specify which model or backend does the actual rewriting, and there's no API key field or model selector in this node's inputs - so I can't tell you exactly what's happening under the hood beyond what the interface and description say. What you can rely on is the contract: give it a prompt, an exclude word, and a replacement, and you get back a prompt with that swap made sensibly rather than mechanically. That output - a plain STRING named user_prompt - is meant to be wired straight into a CLIP Text Encode node or any other prompt-consuming node in your graph, same as you'd use a manually-typed prompt.
Where this actually helps: batch generation where you want the same composition with one element varied - same scene, different outfit color; same subject, different accessory - without hand-editing dozens of prompt variants or risking a naive string replace mangling the sentence around the word you're changing.
Installing it: through ComfyUI Manager, search "ComfyUI Layer Style Advance," or manually clone with git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes, then install_requirements.bat (or the Aki variant) / pip install -r requirements.txt, then run repair_dependency.bat, then restart ComfyUI. This node doesn't need a separate model download of its own - no LLM checkpoint to place in a models folder, no API key file to fill in - so if it's missing from your node list after a normal install, it's very likely a general import failure for the pack rather than something specific to this node. Check for the usual suspects: outdated transformers, or a conflicting opencv/tensorflow install fighting over the same dependency, both of which are known to break the whole pack's import on the first launch after install.
One practical tip: keep exclude_word specific. The more generic the word you're targeting, the more likely the rewrite touches something you didn't mean to change - same failure mode as any find-and-replace, just softened by the node trying to keep things grammatical rather than eliminated outright.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| orig_prompt | STRING | — | |
| template | COMBO | 1 options: prompt replace word | |
| exclude_word | STRING | — | |
| replace_with_word | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| user_prompt | STRING | — |