ComfyUI Node

String Formatter [OLD]

The same node, under the ID your old workflows still call

By Lex-DRL·Created about a year ago·Updated 4 months ago· 5
String Formatter [OLD]
  • dict
  • string
template
recursive_formatfalse
safe_formattrue
show_statustrue

This is the String Formatter node from Lex-DRL's String Constructor pack, wearing its old name. StringConstructorFormatter was the class ID before the author re-versioned the pack (v3.x) and switched to namespaced IDs, and it's still shipped so that every workflow you saved before the rename keeps loading. That's the whole reason it exists. It's marked deprecated and lives under the String Constructor/_old category in the node list, so if you're starting a graph today, add the new "String Formatter" instead - same behavior, no stale-ID baggage.

If you opened an old workflow and this is what you've got, don't worry: it works exactly like the current node. You give it a multiline template containing {placeholders}, optionally connect a dict (the DICT input holding your named chunks), and it fills every {key} from the dictionary and hands the assembled string out of the single string output. Same mechanism - Python's str.format_map() under the hood, same three toggles:

  • recursive_format - let chunks reference other chunks, so {neg_common} can expand into a whole hierarchy of negative-prompt parts.
  • safe_format - on by default; leaves unformattable {patterns} (missing keys, JSON/CSS braces) as-is instead of erroring.
  • show_status - previews the final string on the node.

It's an output node, so it can stand alone as a live preview of what your template compiles to.

Install

ComfyUI Manager → search "String Constructor", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Lex-DRL/ComfyUI-StringConstructor

Restart ComfyUI. The only dependency is frozendict; no models, no heavy installs. Needs ComfyUI 0.18+.

The one genuinely confusing part of this node is the naming. Keys in your dictionary must be valid Python identifiers - ASCII letters, digits, underscores, no leading digit - because they become format() keyword arguments. A key with a space or hyphen won't format, and the validator node exists precisely to catch that. Also note the split since v3.x: dictionary-building nodes moved to the separate ComfyUI-DictTools pack, so a dict fed into this node may have been built there. If you're migrating old workflows, that's the only real adjustment - swap the old node for the new one at your leisure, and everything else keeps working.

CategoryString Constructor/_old

Inputs (5)

NameTypeDefaultDescription
templateSTRINGType the text template. To reference named substrings from format-dictionary, use this syntax: {substring_name}. For example: score_9, score_8_up, score_7_up, {char1_short}, standing next to {char2_short}, {char1_long} {char2_long}
recursive_formatBOOLEANfalseDo recursive format - i.e., allow the chunks from the dictionary to reference other chunks.
safe_formatBOOLEANtrueIf template contains an invalid {text pattern} which can't be formatted - leave it as-is (instead of throwing an error). Safe mode is recommended for templates with JSON, CSS, or other literal curly brackets.
show_statusBOOLEANtrueShow the final string constructed from the text-template and format-dictionary?
dictoptDICTThe dictionary to take named sub-strings from. It could be left unconnected, if the pattern doesn't reference any sub-strings - then, this node acts exactly the same as a regular string-primitive node.

Outputs (1)

NameTypeDescription
stringSTRING