SRL Format String
Build any string in one node, with Python's real format syntax
- in0
- in1
- in2
- in3
- in4
- STRING
ComfyUI's built-in text nodes will concatenate a few strings for you, but the moment you want to assemble a filename from a seed and a step count, or slot a number into a prompt, you're juggling three nodes and a bunch of wires. SRL Format String collapses that into one node: it's Python's str.format() sitting on the graph. Feed it up to five values, give it a template, and it hands you back a string.
How it works
The node takes a single required format template and five optional inputs, in0 through in4, that accept anything. Internally it does format.format(*kwargs.values(), **kwargs) - which is exactly Python's string-format machinery, so the whole syntax works:
{}grabs the inputs in order: first isin0, second isin1, and so on.{2}addresses the third input by index (counting from zero, so{2}isin2).{in4}addresses an input by name.{!r}renders the value withrepr()instead ofstr()- handy for seeing exactly what a value is.- Format specs work too:
{:.2f}will round a float to two decimals,{:04d}pads a number.
One output comes out: a STRING, ready for a text encoder, a filename, a save path, or anything else that wants text.
What you'd use it for
Classic cases: building a save filename like {in1}_{in0}.png from a seed and a batch index, composing a prompt from a few parts, or generating a human-readable label that pairs with your output for debugging. Since inputs are any-typed, you can pipe in numbers, strings, even a bool - str.format will stringify whatever it gets.
The gotchas
The big one: this is str.format, not an f-string. You can't reference a variable by any name you like - the only named slots are in0 through in4, and a template that references an unwired input (say {in4} with nothing connected) throws a KeyError and the node errors out. Check the template against what you actually wired.
Second: literal braces. If your output needs an actual { or }, you have to double them - {{ and }} - otherwise Python reads them as a slot and errors. That bites anyone formatting JSON or code.
And a subtle one: a format spec like {:.2f} expects a float. Feed it an int and some specs misbehave, so if a spec silently produces nothing sensible, check the type coming in.
Install
Part of the same tiny pack as the rest of SRL's nodes, no dependencies, no model downloads. ComfyUI Manager → search "SRL's nodes" → Install, restart. Or:
cd ComfyUI/custom_nodes && git clone https://github.com/seanlynch/srl-nodes
It's a utility node, not a flashy one - the kind you install once and quietly rely on every time you need a string that isn't just a hardcoded prompt.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| format | STRING | first input via str(): {}, second input via repr(): {!r}, third input by index: {2}, fifth input by name: {in4} | — |
| in0opt | * | — | |
| in1opt | * | — | |
| in2opt | * | — | |
| in3opt | * | — | |
| in4opt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |