π Text Template Extended (nhk)
Prompt templates with up to 8 slots
- output
Prompt engineering in ComfyUI quickly turns into a copy-paste problem: "The [something] walks in the [somewhere]" with two or three blanks you want to vary per run. TextTemplateExtended is the node that formalizes that - you write a template with placeholders and get eight dedicated input sockets, one per placeholder, all of which can be wired to other nodes so the blanks fill themselves. It's the bigger sibling of the pack's four-slot Text Template, doubling to [a] through [h].
It lives in nhk/text of the nhknodes pack, and if you've ever used a {prompt} substitution in a shell script, you already understand it. The template is a string; placeholders are replaced with the values on the matching sockets.
How it works
You type a template like The [a] walks in the [b] into the template field. Each optional input - a, b, c, d, e, f, g, h - maps to the placeholder of the same name in brackets. On execution the node does a straightforward string replace: every [a] becomes the value of socket a, every [b] becomes the value of socket b, and so on. The result comes out as the single output STRING.
Because the placeholders are just text, the flexibility is all in how you use them:
- Hardcode slots:
a = "cyberpunk detective",b = "rain-soaked alley". - Wire them to other nodes:
aconnected to a LoadImageSeries's filename,bto a seeded random word node - now each generation gets a fresh, contextual prompt. - Leave slots empty and their placeholders vanish (replaced with empty string), so
The [a] walks in the [b]withbempty becomesThe cyberpunk detective walks in the.
Two things to keep in mind: replacement is literal - there's no escaping, so a literal [a] in your text will always be substituted - and there's no error handling, so an unfilled placeholder silently disappears. That's usually what you want; just don't rely on it for strict prompt formatting.
Installing
The usual pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/Enashka/ComfyUI-nhknodes
or ComfyUI Manager β search "NHK Nodes" β install β restart. Under nhk/text, no models, no extra deps.
Where people get burned
- "My literal [a] got eaten." Yes - that's how placeholder substitution works. If your content legitimately contains
[a](rare for prompts, possible for other text), this node will replace it. The plain TextCombiner is the escape hatch for that. - "The output has gaps where my blanks were." Empty slots become empty strings. If you need a default value, set it in the slot or handle it upstream.
- "I need more than eight." This is the extended version, capped at 8 by design. Chain two templates or use TextCombiner to assemble the rest.
TextTemplateExtended is the kind of node that feels trivial until you realize how many workflows are secretly "one template plus a few rotating inputs." If you're building prompt-variation batches - especially driven by a series loader or a random selector - this is the cleanest way to keep the structure fixed while the details change.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | The [a] walks in the [b] | Template text with [placeholder] syntax. Placeholders: [a] through [h] |
| aopt | STRING | (optional) Value for [a] placeholder | |
| bopt | STRING | (optional) Value for [b] placeholder | |
| copt | STRING | (optional) Value for [c] placeholder | |
| dopt | STRING | (optional) Value for [d] placeholder | |
| eopt | STRING | (optional) Value for [e] placeholder | |
| fopt | STRING | (optional) Value for [f] placeholder | |
| gopt | STRING | (optional) Value for [g] placeholder | |
| hopt | STRING | (optional) Value for [h] placeholder |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | STRING | β |