ComfyUI Node

Text Format

A ComfyUI node in Zuellni/Text with 6 inputs and 1 output.

By Zuellni·Created 3 years ago·Updated 3 years ago· 43
Text Format
    • STRING
    text
    var_1
    var_2
    var_3
    var_4
    var_5

    Prompt assembly in ComfyUI is usually a mess of concatenation nodes. Text Format is the mail-merge node - you write a template with var_1var_5 placeholders in it, and it replaces each with the value of the matching input. One node, five variables, a single string out. It's the pack's simplest text node and the one you'll actually use even if you never touch an LLM.

    What it is

    One required input: text (a multiline template). Five optional string inputs: var_1 through var_5. Output: a single STRING. The mechanism is dead simple - a literal str.replace for each variable. Put the text var_1 anywhere in your template, and it gets swapped for whatever's wired into the var_1 input.

    The mental model

    The placeholders are literally the words var_1, var_2, and so on - not {var_1} or $1 or any fancy syntax. So your template looks like:

    a portrait of var_1, wearing var_2, background var_3, style: var_4
    

    and you wire var_1 → "a knight", var_2 → "a red cloak", etc. One big advantage: the template can span multiple lines, so you can build multi-part prompts - a base style block plus variable content - without stacking half a dozen string nodes.

    Where it shines

    • Batch prompting. Wire var_1 from a "prompt list" loader or an LLM output, keep the template fixed, and every generation gets the same framing with a swapped subject. This is the classic way to A/B test subjects without re-typing prompts.
    • LLM integration. In the pack's text-generation-webui setup, the LLM produces the variable content and Text Format assembles the final prompt that goes to a CLIP encoder. It's the glue between "LLM says this" and "sampler needs a prompt."
    • Repetition without friction. If you find yourself retyping a long stable prefix, it becomes the template and only the variables change.

    The gotcha

    Because it's a literal str.replace, there's no escaping: if your actual prompt text contains the characters var_1, they'll be replaced even if you didn't intend them as placeholders. In practice that's rare - var_1 isn't a natural phrase - but if your content legitimately contains those substrings, shuffle the variable you use. Also, unlike format-string syntax, there's no error if you use a placeholder with no input connected - it just stays as the literal text var_1. So an unconnected variable silently leaves placeholder text in your prompt. Check your wires.

    Install

    Part of Zuellni/ComfyUI-Custom-Nodes, via ComfyUI Manager (search "Zuellni") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Zuellni/ComfyUI-Custom-Nodes
    

    No dependencies, no downloads - pure string handling, and it works standalone, no LLM required. The pack is archived, but this node is too simple to rot; it'll keep working long after everything else in the pack has moved on. If you need more than five variables or fancier templating, core ComfyUI's text nodes plus a few String Format-style nodes cover the rest - but for "template with a few blanks," this is the one you'll grab.

    CategoryZuellni/Text

    Inputs (6)

    NameTypeDefaultDescription
    textSTRING
    var_1optSTRING
    var_2optSTRING
    var_3optSTRING
    var_4optSTRING
    var_5optSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING