ZML_替换提示词
Swap {{提示词}} for anything you wire in
- 结果文本
ZML_替换提示词 is the most transparent node in this pack: it takes a template, a replacement, and a marker, and does a literal find-and-replace. The author's own example, straight from the tooltip and the docstring: template "我是{{提示词}}", replacement "神", marker "{{提示词}}" → output "我是神". That's the whole node, and it's genuinely useful because prompts are the thing you most often want to swap at runtime.
The mechanism is a single str.replace call - no regex, no parsing, nothing clever. That's a feature, not a limitation: what you type is literally what gets substituted, so there are no escaping surprises. The three inputs map cleanly:
- 模板文本 (template) - multiline STRING. Your prompt skeleton containing the marker, e.g.
best quality, {{提示词}}, masterpiece. - 替换内容 (replacement) - multiline STRING. What goes in.
- 替换关键词 (marker) - STRING, default
{{提示词}}. Whatever token you want replaced. Change it if{{提示词}}collides with something else in your workflow.
Output: 结果文本 (STRING).
Why you'd actually reach for it
The workflow that clicks: you keep one "framing" template - quality tags, camera words, style anchor - and you swap the middle in from another node. Wire 替换内容 from a preset-text node or a random-text-weight node, and you get structured templates with a variable core: same frame, different subject, per run. That's the same "one source, many consumers" pattern the plumbing layer lives for, applied to prose. The {{提示词}} convention is a deliberate echo of how the pack's subworkflow system does {{变量名}} substitution, so if you've used that, the mental model carries over.
Two honest caveats. First, it's literal replacement only - case-sensitive, exact match, first marker convention via str.replace (which does all occurrences, actually). If your replacement contains the marker itself you can get recursion, but that's a you-problem, not a node-problem. Second, and this matters more: if you're on an LLM-encoded 2026 model, "prompt framing with quality tags" may not behave like it does on SDXL - the KB's prompt-engineering essay is blunt that a tag bag isn't an instruction. This node is a string tool; it doesn't care which model you feed it to, but you should.
Install
Part of ComfyUI-ZML-Image (160+ nodes, one install). ComfyUI Manager → search ComfyUI-ZML-Image, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
restart. No models, no extra dependencies, zero GPU cost. Chinese-first UI - the README's translation patch helps - and like everything in this one-person pack, genuine bugs belong on the GitHub issues page.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| 模板文本 | STRING | 输入包含替换标记的模板文本,如:我是{{提示词}} | |
| 替换内容 | STRING | 输入要替换到模板中的内容 | |
| 替换关键词 | STRING | {{提示词}} | 设置要替换的关键词标记,默认值为 {{提示词}} |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 结果文本 | STRING | — |