Nodes/ComfyUI-nhknodes/πŸ“ Text Template Extended (nhk)
ComfyUI Node

πŸ“ Text Template Extended (nhk)

Prompt templates with up to 8 slots

By EnashkaΒ·Created 12 months agoΒ·Updated 28 days agoΒ· 23
πŸ“ Text Template Extended (nhk)
    • output
    β—„templateThe [a] walks in the [b]β–Ί
    β—„aβ–Ί
    β—„bβ–Ί
    β—„cβ–Ί
    β—„dβ–Ί
    β—„eβ–Ί
    β—„fβ–Ί
    β—„gβ–Ί
    β—„hβ–Ί

    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: a connected to a LoadImageSeries's filename, b to 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] with b empty becomes The 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.

    Categorynhk/text

    Inputs (9)

    NameTypeDefaultDescription
    templateSTRINGThe [a] walks in the [b]Template text with [placeholder] syntax. Placeholders: [a] through [h]
    aoptSTRING(optional) Value for [a] placeholder
    boptSTRING(optional) Value for [b] placeholder
    coptSTRING(optional) Value for [c] placeholder
    doptSTRING(optional) Value for [d] placeholder
    eoptSTRING(optional) Value for [e] placeholder
    foptSTRING(optional) Value for [f] placeholder
    goptSTRING(optional) Value for [g] placeholder
    hoptSTRING(optional) Value for [h] placeholder

    Outputs (1)

    NameTypeDescription
    outputSTRINGβ€”