String Formatter
Python .format() right in your workflow — great for filenames
- result
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_1…value_5 and number_1…number_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_1in 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}.pngand 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | — | |
| value_1opt | STRING | — | |
| value_2opt | STRING | — | |
| value_3opt | STRING | — | |
| value_4opt | STRING | — | |
| value_5opt | STRING | — | |
| number_1opt | INT | 0 | Number value 1 |
| number_2opt | INT | 0 | Number value 2 |
| number_3opt | INT | 0 | Number value 3 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |