ComfyUI Node

String Format

Drop values into a prompt template with String Format

By kale4eat·Created 2 years ago·Updated 2 years ago· 7
String Format
  • object
  • string
format

String Format is the closest thing this pack has to a template engine - and it's a one-slot template engine. You write a string with a placeholder in it, plug a value into the object input, and it renders. Simple, and genuinely handy once you realize how many workflows are "fixed sentence with one number or word that changes."

What it does

Under the hood it calls Python's format.format(object), which is the built-in string templating method. Your format input is the template, object is the value to inject. The placeholder is a bare {} - anything inside the braces gets replaced by the string form of whatever you connect to object.

So "Step {}. Ready." with a value of 4 becomes "Step 4. Ready.". Filenames, prompts, log strings - anything with a single variable slot is fair game.

The neat part is the object input is a wildcard (*), so you're not limited to strings. Wire in a seed, a width, a boolean, whatever node output you want, and it gets stringified automatically. That's the same trick the pack's String Str node does explicitly.

The inputs and outputs

  • format (STRING, required) - your template, e.g. "masterpiece, {}".
  • object (wildcard, optional) - the value that fills the {}. Leave it unconnected and you get the literal text "None" in its place.
  • string (STRING) - the rendered result.

Two format-string notes, because Python is picky. Use {} or {0} - both work. A named placeholder like {name} will raise a KeyError and crash the node, because this pack passes one positional argument, not a dict. And there's only one slot: you can't do "{} and {}" with two different values in one node. Chain two String Formats or reach for String Concat when you need multiple variables.

How to install it

Same as every node here - a dependency-free repo:

cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-string-util

or ComfyUI Manager → search "ComfyUI-string-util" → restart. It appears under the string-util category.

Common issues

The KeyError on named placeholders is the trap most people hit first - if you've used Python before and habitually write {name}, this node will fail on you. Keep to {}. The other quiet failure is an empty format string: it just outputs an empty string, no error, which is a slow way to discover a disconnected wire.

Categorystring-util

Inputs (2)

NameTypeDefaultDescription
formatSTRING
objectopt*

Outputs (1)

NameTypeDescription
stringSTRING