Replace or Insert Tag
Swap one tag out of a bigger prompt string
- STRING
This is the node for when you've got a big block of tag-style prompt text - from a Load Preset output, a saved character sheet, whatever - and you need to change one tag in it without retyping the whole thing. Find the tag matching a pattern, either swap it out or add something next to it.
How it works
You give it text (the full prompt block), a pattern to find the tag by, and a value to act with. mode decides what happens at the match: replace swaps the matched tag out entirely for value; insert appends value alongside it instead of removing anything. The README's own summary is blunt: "Replace (mode=replace) or append (mode=insert) the value to the tag matching the pattern" - which is exactly what it does, no more.
The interesting field is inherit_weight. This pack ships Prompt Weight and Round Prompt Weight right alongside this node, all built around the same (tag:weight) attention syntax, and inherit_weight is clearly designed to work with that family: turn it on and if the tag you matched was already weighted - say (1girl:1.2) - the replacement keeps that same 1.2 instead of resetting to neutral. Handy if you're swapping the subject of a heavily-tuned prompt without wanting to re-balance every weight by hand.
Inputs and outputs that matter
- text - the multiline prompt block you're editing.
- pattern - what identifies the tag to act on. The README doesn't spell out whether this is a literal substring match or something regex-like, so test it on one line before trusting it in a batch of presets.
- value - what gets swapped in or appended.
- mode -
replaceorinsert. - inherit_weight - carry the matched tag's existing weight onto the new value, boolean, off by default.
Output is a single STRING - the edited prompt block.
Installing it
ComfyUI Manager → search ComfyUI-PromptUtilities → install → restart. Or:
cd ComfyUI/custom_nodes && git clone https://github.com/nkchocoai/ComfyUI-PromptUtilities
No models, no extra dependencies. You'll find it filed under the PromptUtilities category once ComfyUI restarts.
Where it actually fits in a workflow
The natural pairing is downstream of Load Preset: pull in a canned tag block, then use this node to tweak the one detail you don't like - swap "maid outfit" for "school uniform", or bump a specific tag's emphasis - without hand-editing the whole preset or forking a new CSV row for every small variation.
Where people get burned
Two things worth checking before you trust this in a real batch. First, pattern matching semantics - confirm on a short test string whether it's finding a whole tag or a loose substring, because a loose match against a common word could catch more than you intended in a long comma-separated block. Second, inherit_weight only makes sense - and only does anything - on CLIP-family models (SD1.5, SDXL). The (tag:weight) syntax it's preserving is dead weight, literally, on the LLM-encoded models like Flux.2 and Z-Image, where parentheses and colons are just characters the encoder reads as-is.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| pattern | STRING | — | |
| value | STRING | — | |
| mode | COMBO | 2 options: replace, insert | |
| inherit_weight | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |