ComfyUI Node

String Formatter

Named placeholders, no regex required

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
String Formatter
    • STRING
    format_stringResult: {input1}, {input2}
    input1
    input2
    input3
    input4
    input5

    String Formatter builds a string from a template and up to five input values. You write a format string with placeholders like {input1}, wire up the inputs, and it fills them in. It's Python's str.format() exposed as a node, which makes it the straightforward pick for "I have five values and I want them in one sentence."

    The use cases are the boring-but-everywhere ones: constructing a dynamic prompt from a subject, style, and artist that each come from their own picker; building a filename like {input1}_{input2}_{input3}.png from workflow variables; composing an API request or a status message; or stitching together an LLM prompt with a few dynamic fields. Compared to the pack's other formatter (Text Template), this one is friendlier: placeholders use the same inputN names as the ports, so you don't have to translate between socket names and template syntax.

    How it works

    The format string is run through format() with input1input5 as the named arguments. Placeholders match the port names exactly: {input1}, {input2}, and so on. Leave an input unwired and its placeholder fills with the empty string - which is usually what you want, though it can leave stray doubled spaces (" , " kind of output) if your template assumes the input exists. The default template, "Result: {input1}, {input2}", works out of the box, which is more than can be said for some nodes in this pack.

    The inputs that matter

    • format_string - the template with {inputN} placeholders.
    • input1input5 - the five slots. All optional, all multiline.

    One output, a STRING - the formatted result, ready for a CLIP encoder, filename builder, or text saver.

    Gotchas

    The error model is the thing to internalize. If your format string references a placeholder that doesn't exist - say you typed {input6} but the node only goes to five - it doesn't crash. It returns the literal string "Error: Missing input for key 'input6' in format string." as your output. Useful, but easy to miss if you're not looking at the actual text flowing through, and it means a typo'd template quietly poisons downstream. A stray literal { in the template throws a ValueError, which you'll see as a similar error string.

    String Formatter vs. Text Template

    This pack genuinely ships two of these. Text Template accepts four inputs, allows positional {0} and {val1} naming, and accepts non-string input types; String Formatter gives you five named inputs and only takes strings. For most people, String Formatter is the one to reach for - the naming is self-documenting and five slots covers more cases. Text Template's edge is positional flexibility. Use one, not both.

    Installation

    ComfyUI Manager → search "DebugPadawan's ComfyUI Essentials", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git
    

    Restart ComfyUI. No models, no extra dependencies - pure string formatting.

    CategoryDebugPadawan/Text

    Inputs (6)

    NameTypeDefaultDescription
    format_stringSTRINGResult: {input1}, {input2}
    input1optSTRING
    input2optSTRING
    input3optSTRING
    input4optSTRING
    input5optSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING