ComfyUI-AICoser Prompt Template
@1 goes here — a dead-simple prompt template with a live preview
- text
A prompt is rarely one blob. It's a subject, a style, a lighting setup, a camera angle, and you keep changing one piece while leaving the rest alone. AICoser_PromptTemplate is the node that makes that composition explicit: you write a template with @1 through @8 placeholders, wire up to eight text sources into it, and it stitches them together into a single string.
It's the kind of tool that reads as over-engineered until you've rebuilt the same prompt by hand a dozen times. Put your fixed phrasing in the template once, keep subject/style/lighting in separate little text boxes, and you can swap one without touching the others. The README's example is in Chinese but the idea is language-agnostic: a template like a @1 woman wearing @2 clothes with @1 = beautiful, @2 = red renders to a beautiful woman wearing red clothes.
How it works
The substitution is a simple regex: the template is scanned for @(\d+) and each placeholder is replaced with the content of the matching textN input. Two details make it nicer than a naive find-and-replace:
- It nests. If
text1's content itself contains@2, that gets resolved too, recursively - up to 10 levels deep, which is also the recursion guard. You can compose templates out of templates without an infinite loop. - It previews live. The pack ships a frontend extension that renders the final string in a preview box inside the node as you type and connect wires. No queueing up a run just to see what your template expands to.
The node also implements IS_CHANGED by hashing the template and all eight texts, so the graph correctly reruns whenever any piece of the prompt changes - no stale-cache surprises.
The inputs that matter
- template - required, multiline. This is where
@1…@8live. Unconnected slots substitute as empty strings, so a placeholder for a missing input silently vanishes rather than erroring. - text1 … text8 - all optional and wire-in only (they're
forceInput, so you connect a TextBox or any STRING source rather than typing into them). That's the point: the values come from the graph, not the widget.
Output: a single text (STRING) - the rendered prompt. Wire it into a CLIP Text Encode for SDXL/Flux, or into this pack's PromptQueue if you're building a batch.
Installing it
Same pack as the rest of ComfyUI-AICoser-Tools:
cd ComfyUI/custom_nodes
git clone https://github.com/aicoser-sister/ComfyUI-AICoser-Tools
Restart ComfyUI (or use ComfyUI Manager → search "ComfyUI-AICoser-Tools"). No extra dependencies beyond what ComfyUI already ships - this node is pure string handling.
Common issues
- Placeholder stays as
@1in the output - you're referencing a slot with no wire connected, so it substitutes the empty string. If you're expecting a real value, check the wire. (A placeholder outside 1–8 is left untouched, which is the only time you'll see a literal@N.) - The preview box doesn't appear - the live preview is a frontend extension; if you're on a heavily modified frontend or loaded the workflow from an API-only client, it may not render. The node still works fine; you just lose the convenience.
- "Too much nesting" - you can't exceed 10 recursive levels; templates referencing each other in a loop just stop resolving at depth 10 rather than hanging.
One take: it's positional @N rather than named placeholders or wildcard-style __random__ files, so it's simpler than rgthree or wildcard systems - but simple is exactly why it's predictable. For a fixed frame around variable content, this is the one I'd reach for.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | — | |
| text1opt | STRING | — | |
| text2opt | STRING | — | |
| text3opt | STRING | — | |
| text4opt | STRING | — | |
| text5opt | STRING | — | |
| text6opt | STRING | — | |
| text7opt | STRING | — | |
| text8opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |