Nodes/Quality of life Suit:V2/replace String _O
ComfyUI Node

replace String _O

Find-and-replace for the old string suite

By omar92·Created 3 years ago·Updated 5 months ago· 181
replace String _O
  • string
  • STR
old
new

replace String _O does find-and-replace on a string: give it a source string, an old substring, and a new substring, and it returns the string with every occurrence of old swapped for new. Useful idea, but here's the thing you need to know before you build anything on it: it's deprecated and it speaks the pack's old STR type, not ComfyUI's native STRING.

The node lives in O/deprecated/string/operations of the Quality of Life Suit pack, and that "deprecated" prefix is doing real work. This whole string subsystem is the pre-merge version of the pack - before it was consolidated, string handling used a custom STR type (a dict wrapper) that only wires to other deprecated nodes like String _O, concat Strings _O, and trim String _O. The modern equivalent - Replace Text _O under O/text/operations, which takes and returns native STRING - is what you should use for anything new.

How it works

Under the hood it's a single Python str.replace() call: string["string"].replace(old, new), replacing all occurrences (not just the first). The mixed-type detail is where it gets weird:

  • string (STR) - the deprecated dict-wrapped source. Must come from another STR node.
  • old (STRING) - the substring to find. Note: this one is a native widget string, not STR.
  • new (STRING) - the replacement, also a native widget string.

One output: STR, the modified string (still in the deprecated type).

So the inputs are a type collision: the source needs the old type, but the find/replace text are plain widgets. That's fine if you're staying inside the legacy suite, and confusing if you're not.

Where it fits

Honestly: it fits in old workflows, and nowhere else you should be building. If you load a graph that predates the pack's merge and it pulls in String _Oreplace String _O, let it run - it works, and it's why the pack keeps deprecated nodes around. The moment you want to do string surgery in a modern graph (native STRING from Text _O, Concat Text _O, a RandomNSP output), use Replace Text _O instead. Same idea, right type, no deprecation warning hanging over your head, and the whole deprecated suite is slated for eventual removal anyway.

Installing it

Part of the Quality of Life Suit pack (omar92/ComfyUI-QualityOfLifeSuit_Omar92). Install via ComfyUI Manager (search "Quality of Life Suit") or clone:

cd <ComfyUI>/custom_nodes
git clone https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92.git

Restart ComfyUI properly. No models, no dependencies.

Common issues

  • "The wire won't connect to my modern text node." Expected - STR vs STRING mismatch. This is the classic reason people land here. Switch to Replace Text _O.
  • "Only the first occurrence changed." No - str.replace replaces all of them. If only one changed, your old string only appears once.
  • "It disappeared after an update." The deprecated suite is on the removal track. Migrate to the modern O/text nodes.

One-line summary: a working find-and-replace that you should treat as compatibility glue, not a tool for new work.

CategoryO/deprecated/string/operations

Inputs (3)

NameTypeDefaultDescription
stringSTR
oldSTRING
newSTRING

Outputs (1)

NameTypeDescription
STRSTR