Nodes/ComfyUI-AutoFlow/String Formatter
ComfyUI Node

String Formatter

Python .format() right in your workflow — great for filenames

By ZXL-Xinram·Created about a year ago·Updated 9 months ago· 4
String Formatter
    • result
    template
    value_1
    value_2
    value_3
    value_4
    value_5
    number_10
    number_20
    number_30

    String concatenation gets you far until it doesn't. The moment you want a filename that zero-pads an index (image_042.png), pads a seed, or orders several variables cleanly, gluing strings together becomes a mess of separators and hand-formatting. String Formatter gives you Python's .format() syntax inside a node: write a template with {placeholders}, fill in the values, get a clean string out.

    This is the node you'll reach for to build save prefixes, prompt templates, and any string where formatting matters.

    How it works

    You write a template using Python format fields, and the node fills them from its inputs. The naming is the small gotcha: the widgets are value_1value_5 and number_1number_3, but inside the template they're referenced as {value1} or {v1} (strings) and {number1} or {n1} (numbers). So the README's example template {v1}_{n1:03d}.png with value_1=image and number_1=42 produces image_042.png - the :03d is the zero-padding format spec.

    Because it's real str.format, you get the full format spec grammar: {n1:.2f} for two decimals, {v2:>10} for padding, whatever you'd use in Python.

    Inputs

    • template - required. The format string with placeholders.
    • value_1 … value_5 - optional string values.
    • number_1 … number_3 - optional int values.

    Output

    result - the formatted string. If formatting fails (bad syntax, unknown placeholder), it returns the original template and logs a message - so a typo degrades gracefully rather than killing the queue.

    Install

    Standard pack install - ComfyUI Manager (search "ComfyUI-AutoFlow") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
    

    Restart after. No dependencies.

    Where people get burned

    • The name mismatch. value_1 in the widget, {value1} in the template. Forget the underscore-to-nothing translation and the placeholder won't resolve.
    • Only three numbers. If you need more numeric inputs, chain two Formatter nodes or fold the numbers into value slots (they'd come out as strings, which is fine for filenames).
    • {v1} and {value1} are the same slot. It's an alias, not a separate value - easy to assume {v1} and {value1} are different things and then wonder why one overwrites the other.
    • Returning the raw template on error can be genuinely confusing - an invalid template silently outputs {v1}_{n1:03d}.png and you'll see literal braces in a filename.

    For output naming, this is arguably the most useful node in the pack's string section. Zero-padded counters alone justify it - img_001.png sorting properly in file explorers is a small, real victory.

    CategoryAutoFlow/Utilities

    Inputs (9)

    NameTypeDefaultDescription
    templateSTRING
    value_1optSTRING
    value_2optSTRING
    value_3optSTRING
    value_4optSTRING
    value_5optSTRING
    number_1optINT0Number value 1
    number_2optINT0Number value 2
    number_3optINT0Number value 3

    Outputs (1)

    NameTypeDescription
    resultSTRING