Nodes/Comfyui-General-API-Node/Text Template (FeiMao-326)
ComfyUI Node

Text Template (FeiMao-326)

Type {subject} in a template, get an input port. The prompt-builder that meets you halfway

By FeiMao-326·Created 12 months ago·Updated 5 months ago· 0
Text Template (FeiMao-326)
    • text
    template

    Prompt templates are the boring glue of every decent workflow. You want "a {subject} in {style} lighting, {mood} background" to actually become three separate inputs you can wire other nodes into - not a string you hand-edit every run. This node does exactly that, and it does it in a way that feels almost too simple: type a variable, get a port.

    How it works

    There's one input, template, a multiline box. Write your template with {variable} placeholders - any name you like, and it works for non-ASCII names too, since the matching is Unicode-aware rather than English-only. A bundled JS extension watches the template widget and creates an input slot for every unique {var} it finds. Those slots are universal type ("*"), so you can wire in anything from a Simple Text node, an LLM output, or a loaded file - anything that resolves to a string gets stringified.

    The actual substitution is plain and predictable: each {var} in the template is replaced by whatever is connected to that slot. Two behaviors worth knowing:

    • Unfilled variables stay as-is. If a slot is left disconnected, the literal {var} text survives in the output instead of vanishing. That's deliberate - it lets you nest templates or partially fill them without mangling the rest - but it also means a forgotten wire shows up as a weird {subject} in your final prompt. Easy to spot, easy to fix.
    • Variables only create slots while they're in the template. Remove the {style} bit and the port disappears with it.

    Using it in a real workflow

    The typical setup: Simple Text nodes (or better, outputs from an LLM node) feed into the dynamic slots, and the text output feeds straight into a CLIP Text Encode. It's the natural companion to the pack's JSON Parser - parse shot and scene out of an LLM response and slot them straight into your template without a single manual copy-paste.

    One quirk the author calls out directly: in the newer Nodes 2.0 (Vue) UI, after you edit the template's variables, right-click the node and hit "Refresh" to regenerate the slots. In the classic UI it usually just works as you type, but if you've upgraded and your new {var} isn't spawning a port, that refresh is the fix.

    Inputs and outputs

    • template (STRING, multiline) - your text with {variable} placeholders. There's a handy placeholder example: A {subject} in {style} style.
    • text (STRING) - the rendered result, one output.

    That's the whole node. No mode toggles, no delimiter settings, no footguns beyond the refresh quirk. It's the kind of utility you install and immediately forget is a custom node because it just behaves the way you'd hope.

    Installing

    It's part of the FeiMao-326 pack, so install once and you get all sixteen nodes. ComfyUI Manager (search "Comfyui-General-API-Node") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/FeiMao-326/Comfyui-General-API-Node.git
    cd Comfyui-General-API-Node
    pip install -r requirements.txt
    

    Restart ComfyUI afterward. The JS frontend that generates the dynamic slots lives in the pack's js/ folder, so if slots ever fail to appear, make sure that folder made it across the install.

    CategoryFeiMao-326

    Inputs (1)

    NameTypeDefaultDescription
    templateSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING