CNP Format
Build workflow strings with printf placeholders, no Python required
- arg_1
- text
CNP Format is a printf-style string builder for your graph. You give it a template like Size: %u x %u | Prompt: %s, plug values into the arg_1, arg_2, … inputs that grow as you connect wires, and out comes one tidy STRING. If you've ever wanted a saved filename that bakes in the actual resolution and CFG, or a caption that records the settings that made the image, this is the node you reach for.
Why not just build the string yourself? Core ComfyUI has no string-concat node, and its text widgets are static labels. This is the graph-native version of an f-string, and the default template is straight from the classic use case: Size: %u x %u | Prompt: %s.
How it works
Under the hood it's literally Python's % operator, exposed to the graph. The pack's JS makes the argument inputs self-expanding: connect arg_1 and an empty arg_2 appears; plug that and arg_3 shows up. The node reads the placeholders out of your format string, coerces each value to match (%u/%d → int, %f → float, %s → string), and formats. Nothing cached, nothing heavy - it runs in microseconds.
The placeholders: %s, %u/%d/%i, %f/%e/%g, %x/%X/%o, %c, and %% for a literal percent sign. Width and precision work too, so %.1f gives you one decimal place.
The inputs that matter
format- the template, and honestly the whole game. It's multiline, so a two-line caption is fine.arg_1- a wildcard (*) input that accepts any primitive. More slots appear as you connect.
Output
text (STRING). Wire it into a CLIP Text Encode node for a prompt assembled from parts, into a filename/prefix for Save Image, or into a text display node to eyeball what it produced before it goes anywhere important.
Install
Same pack as CNP Random Resolution, so one install covers both. ComfyUI Manager → search "ComfyNodesPlus", or:
cd ComfyUI/custom_nodes
git clone https://github.com/chemicalshock/ComfyNodesPlus
Restart ComfyUI. There's no requirements.txt in the repo - pure stdlib - so unlike a lot of utility packs, this one can't fight your other dependencies over versions.
Where people get burned
- Count your placeholders. If the template wants three args and you've only connected two, the node raises a readable error instead of guessing. Extra connected args are silently ignored.
%%is the only way to write a literal percent. A bare%makes Python throw.- The wildcard accepts anything, but this is for numbers and strings. Wire an IMAGE into
%sand you'll get a tensor repr, which is almost certainly not the caption you wanted. - The expanding arg inputs come from the pack's JavaScript, so a freshly cloned node may only show
arg_1until you've restarted ComfyUI and let the frontend load it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| format | STRING | Size: %u x %u | Prompt: %s | — |
| arg_1 | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |