ComfyUI Node

Text Template

Only {var1}–{var5} Get Replaced — Don't Trust the Default Template

By turnbros·Created 11 months ago·Updated 10 months ago· 0
Text Template
    • text
    templateHello {name}, welcome to {place}!
    var1
    var2
    var3
    var4
    var5

    The one thing that will trip you up

    The default template reads Hello {name}, welcome to {place}! - and if you hit Run without touching it, that's literally what comes out, braces and all. This node only substitutes {var1} through {var5}. {name} and {place} are decorative. The docstring advertises "custom named placeholders" as a feature; the code doesn't implement any. Change the template to {var1} and {var2} (or leave the vars empty) or your "template" gets passed through untouched.

    What it actually does

    ComfyBros Text Template is a string-formatter node: you write a prompt skeleton with up to five placeholders and fill them from anywhere in the graph - a caption or tag node, a random-prompt generator, a seed counter, even the metadata output of this pack's video nodes if you want to feed numbers back in. It's the ComfyUI equivalent of a Python f-string dropped into the middle of a workflow.

    Reach for it when you're assembling prompts from pieces. Swap a subject, a style token, or a location into a fixed skeleton without hand-editing three separate text nodes every time you change one word. The wider ecosystem is full of fancier prompt-tooling nodes, but for "stick five strings into a template," this is about as direct as it gets.

    How it works

    Under the hood it's a plain .replace() pass, in order, var1 through var5. Only non-empty variables get substituted: leave var4 empty and a literal {var4} survives into the output and straight into your sampler's positive prompt, where the model will read it as garbage text. There's also no escaping - if a value you feed in contains {var2}, the later replacement fires on the freshly inserted text too. For a five-slot formatter that's a fair trade; just know what you're getting.

    The inputs and the output

    • template - the multiline string skeleton, with {var1}{var5} placeholders.
    • var1var5 - optional strings, default "". The only things that actually get replaced.
    • Output: text (STRING) - wire it into any prompt input, e.g. the positive_prompt of ComfyBros Text to Video.

    Installing

    Easiest via ComfyUI Manager - search for "ComfyBros". Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/turnbros/ComfyBros
    

    Then restart ComfyUI. One wrinkle: the README tells you to run pip install -r requirements.txt, but no requirements.txt exists in the repo - the command just fails. It doesn't matter for this node. It's pure string operations and needs nothing beyond what ComfyUI already ships; the declared dependencies (pillow, numpy, requests) are all present in any working ComfyUI install.

    Troubleshooting

    • Output still contains braces - you used {name}-style placeholders, or you left a var empty. Both cases pass the template through unmodified.
    • Only five slots - need more variables than that? Chain two templates, or reach for a purpose-built text-utility node; this one is deliberately minimal.
    • The dependable node in the pack - worth saying: unlike its siblings, this one needs no API key, no instance, no cloud account. The video nodes in ComfyBros all demand a configured RunPod endpoint. This one just works, and that's kind of the point.
    CategoryComfyBros/Text

    Inputs (6)

    NameTypeDefaultDescription
    templateSTRINGHello {name}, welcome to {place}!
    var1optSTRING
    var2optSTRING
    var3optSTRING
    var4optSTRING
    var5optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING