Nodes/ComfyUI_MieNodes/String Format ๐Ÿ‘
ComfyUI Node

String Format ๐Ÿ‘

ComfyUI Node Guide

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
String Format ๐Ÿ‘
  • value_0
  • value_1
  • value_2
  • value_3
  • value_4
  • value_5
  • value_6
  • value_7
  • value_8
  • value_9
  • value_10
  • value_11
  • value_12
  • value_13
  • value_14
  • value_15
  • result
โ—„templateโ–บ

If StringConcat is the pack's answer to "join two things," String Format is the answer to "I need a template with several moving parts and I don't want to chain concat nodes five deep to get there." It's Python's str.format() brought into the graph: write a template with {0}, {1}, {2}... placeholders, wire a value into each slot, get the assembled string back. Standard format specs work too - {0:>5} for padding, {0:.2f} for rounding a float to two decimals - so it's not just substitution, it's real formatting.

The UI trick worth knowing about. You don't get sixteen empty sockets cluttering the node the moment you drop it. Only value_0 and value_1 show up at first; the next slot appears automatically the moment you connect something to the last visible one, up to a ceiling of 16. The pack's own docs credit this pattern to Bernini's conditioning-node UX - the same ByteDance prompt-enhancement library MieNodes borrows for its BerniniPromptGenerator node - so if it feels familiar, that's why. Practically it means you only ever see as many inputs as you're actually using, which keeps a template with three or four values from turning into a wall of unused sockets.

Inputs that matter. template is the required format string - this is the one field you always fill in by hand. value_0 through value_15 are optional and, per the node's own schema, accept any type at all, not just text - plug in a number, a boolean, or another node's raw output and it'll get coerced to its string form when substituted in. Any slot you leave unconnected is treated as an empty string rather than erroring, so a template referencing {2} with nothing wired to value_2 just renders that gap as blank instead of failing the run.

Output. result - the formatted string. And here's the detail that actually matters for debugging: if your template is malformed (mismatched braces, a bad format spec), the node doesn't crash your whole run. It logs a diagnostic and passes the raw, unformatted template through on the result wire instead, so you can see exactly what's wrong on the output rather than losing the run entirely. That's a deliberately forgiving design choice, and it's worth knowing about before you assume a weird-looking output means the node is broken - check the console for the diagnostic first.

A worked example, straight from the README: template "{0} + {1} = {2}" with value_0="1", value_1="2", value_2="3" produces "1 + 2 = 3". Swap in real values - a translated caption, a model name from an LLM connector, a hash from StringHash - and you've got a reusable filename pattern, a log message, or a structured prompt built from several upstream nodes in one place.

Install. Search "ComfyUI_MieNodes" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/MieMieeeee/ComfyUI-MieNodes and restart ComfyUI. No dependencies, no models - pure string formatting.

Troubleshooting. A literal brace in your output that shouldn't be there almost always means you forgot to escape it - use {{ and }} to emit a real { or } character, since a single unescaped brace gets read as the start of a placeholder. If result comes back looking exactly like your unedited template, that's the malformed-template fallback kicking in - check the logged diagnostic rather than staring at the template trying to spot the typo yourself. And if a value you expected to see is missing from the output, confirm that slot is actually wired; an unconnected value_N renders as nothing, silently, which can look like a formatting bug when it's really just a missing connection.

Category๐Ÿ‘ MieNodes/๐Ÿ‘ String Operator

Inputs (17)

NameTypeDefaultDescription
templateSTRINGโ€”
value_0opt*โ€”
value_1opt*โ€”
value_2opt*โ€”
value_3opt*โ€”
value_4opt*โ€”
value_5opt*โ€”
value_6opt*โ€”
value_7opt*โ€”
value_8opt*โ€”
value_9opt*โ€”
value_10opt*โ€”
value_11opt*โ€”
value_12opt*โ€”
value_13opt*โ€”
value_14opt*โ€”
value_15opt*โ€”

Outputs (1)

NameTypeDescription
resultSTRINGโ€”