Format: String (lab)
The string-formatting node that replaced three others in my workflows
- formatted
Format: String (lab) is a text template with unlimited inputs, backed by Python's str.format(). You write a template like a portrait of {arg0}, {arg1} and plug any number of strings, integers, floats, or booleans into it; the node replaces the placeholders and hands you the finished string. ComfyLab's README calls it "one node to rule them all," and honestly, that's the pitch.
It collapses the string operations people otherwise stack three nodes deep - concatenation, prefix/suffix insertion, padding, truncation, reordering - into a single template. Instead of "Concatenate + prefix + trim," you write "{arg0:>20}: {arg1}" once and it does the whole thing.
How it works
The template can reference inputs two ways: by name ({arg0}, {arg1}, …) or by index ({0}, {1}, …). Inputs connect to the node dynamically - add as many as you need, and they're typed: STRING, INT, FLOAT, BOOLEAN. Because it's real Python format() under the hood, you get the whole format specification mini-language for free: padding ({arg0:>10} right-aligns), zero-padding, truncation ({arg0:.5}), number formatting ({arg0:.2f}), even repeat-arg tricks. The tooltip points you at "python format" - the pyformat.info guide is the canonical cheat sheet if you want to go deep.
Input: format (the template). Output: formatted (the resulting string).
Where it earns its keep
- Building prompts dynamically - a template with
{subject},{style},{quality}inputs turns a fixed prompt into a fill-in-the-blank that other nodes (or a queue) can vary. - File naming - assemble output filenames from seed, CFG, and sampler values:
img_{seed}_{cfg:.1f}.png. - Header text for grids - ComfyLab's XY plot header formats use the same templating language, so skills transfer directly.
- Anywhere you'd glue strings - this is the single node replacement for a whole chain of concatenation.
Install
ComfyLab Pack installs as one package (nodes display with "(lab)" suffixes). ComfyUI Manager: search ComfyLab Pack, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/bugltd/ComfyLab-Pack.git
cd ComfyLab-Pack
pip install -r requirements.txt
Restart after. No model files; light requirements.
Gotchas
- Braces are the syntax - literally. A template with an unmatched
{is a run-time error, and if you need a literal brace in the output you escape it as{{. The default template text (first arg by name: {arg0}, second by index: {1}) is a good sanity check that the node works. {arg0}vs{0}both work, don't mix them in one template unless you know exactly what you're doing - positional and keyword references resolve differently.- Only the listed types validate - STRING, INT, FLOAT, BOOLEAN. Something exotic won't connect;
Convert to Anywon't rescue it either, since format needs a real value to stringify.
It's the rare utility node where "boring" is a compliment: it does one well-defined thing, it does it via a language you can look up, and you'll forget it's even in the graph until you need a string built. That's exactly the kind of node that earns permanent residency in a workflow.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| format | STRING | first arg by name: {arg0}, second by index: {1} | placeholders can be either '{arg0}', '{arg1}, ... or '{0}', '{1}', ... |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| formatted | STRING | — |