Nodes/String Utils/Text Formatter (2 Arguments)
ComfyUI Node

Text Formatter (2 Arguments)

Finally, a prompt you build from parts

By exectails·Created 2 years ago·Updated 7 months ago· 3
Text Formatter (2 Arguments)
    • text
    format
    arg0
    arg1

    Somewhere between "prompt is a single text box" and "prompt is generated by an LLM" lives the format string, and this is the node that finally makes it usable in ComfyUI. Instead of pasting a whole prompt every time, you write a template once, feed it two values, and let the node stitch it together. It sounds trivial until you've spent an afternoon editing the same sentence across ten workflow copies.

    What it does

    Text Formatter (2 Arguments) takes a format template plus two string arguments and produces one output string. The README's example says it all: format "Hello, {arg0}! Did you know? {arg1} is the answer to everything." with arg0="John" and arg1=42 gives you "Hello, John! Did you know? 42 is the answer to everything." That's the whole deal - variable substitution into a template.

    Where it shines is prompt composition. Build a reusable prompt skeleton, feed it a subject from one node and a style from another, and you can vary one part without touching the rest. Pair it with the ITOA/FTOA converters in this same pack to inject numbers, or with wildcard-style dynamic prompts (the author's companion pack, et_dynamicprompts, is literally linked from the README) for even more flexibility.

    How it works - read this, it bites

    This is Python's str.format() under the hood, called with named keyword arguments: format.format(arg0=..., arg1=...). Two consequences:

    • You must use named placeholders - {arg0} and {arg1}. Positional {} placeholders won't pick up the values and will crash the node.
    • If your template references {arg2} (or any name this node doesn't provide), you get a KeyError. The 2-argument node only knows two names.

    Want a literal brace in your output? Double it - {{ and }} - exactly like Python.

    The inputs that matter

    • format - the template. Multiline, and it's the one field you actually type into.
    • arg0, arg1 - both STRING inputs, and both forceInput: there are no text boxes. You wire values in from other nodes. Use a Primitive if you just want to type a value in the graph, or chain output from a converter, Split Text, or another formatter.

    Output: text, a single STRING - wire it into a CLIP Text Encode or wherever your prompt goes.

    How to install it

    Part of the exectails/comfyui-et_stringutils pack ("String Utils"). Through ComfyUI Manager, search "String Utils"; or clone manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/exectails/comfyui-et_stringutils
    

    Restart, and the formatter nodes sit under exectails/Strings. No pip requirements, no model downloads - pure Python, nothing to go wrong at install time.

    Common issues

    • KeyError: 'argN' - template references a slot the node doesn't have. Either fix the placeholder or use the 5- or 10-argument sibling in the same pack.
    • IndexError on empty {} - positional placeholder with named args. Write {arg0}.
    • "Why are there no text boxes on arg0/arg1?" - because of forceInput. Wire values in; this is by design, not a broken install.
    • Extra unused args are fine - format.format() ignores keyword arguments the template doesn't reference, so a template using only {arg0} works fine on this node.

    The 2-arg version is the most-used formatter in the pack, and the one people hit first. Outgrow it? There's a 5-arg and a 10-arg waiting in the same menu.

    Categoryexectails/Strings

    Inputs (3)

    NameTypeDefaultDescription
    formatSTRING
    arg0optSTRING
    arg1optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING