π€ CR Text Replace
Find-and-replace for your prompts, up to three swaps
- STRING
- show_help
CR Text Replace is find-and-replace for a string, right inside your graph - up to three swaps in one node. You feed it text, tell it "replace this with that" up to three times, and it hands back the edited string. It's the node you reach for when you've got a prompt template and you want to fill in the blanks programmatically instead of retyping.
The classic use is placeholders. Write a prompt like a photo of __subject__ in __setting__, cinematic lighting, then use Text Replace to swap __subject__ and __setting__ for whatever this run needs. Or sanitize incoming text - strip a token you don't want, normalize a phrasing, kill a trailing tag. Anywhere your prompt is assembled from parts you don't fully control, this is a cheap way to patch it before it hits CLIP.
How it works
Straight string substitution: for each find/replace pair you fill in, it replaces every occurrence of the "find" text with the "replace" text. The three pairs apply in order - find1 first, then find2, then find3 - which matters if one replacement produces text that a later pair would also match. Pairs you leave blank are simply skipped. There's no regex here; it's a literal match, so __subject__ finds exactly __subject__, nothing fancier.
The inputs and outputs that matter
text- the string to operate on (multiline). Required. Wire it from a CR Text node or type your template in directly.find1/replace1,find2/replace2,find3/replace3- the three optional swap pairs. Fill in as many as you need; empty ones do nothing. A find with an empty replace just deletes the matched text, which is a handy way to strip a token.
Outputs:
STRING- the result, wildcard-typed so it drops into any string socket.show_help- wiki link, leave it.
Where it bites: it's literal and case-sensitive, so Cat won't match cat. And with only three pairs, it's meant for a handful of targeted swaps, not bulk text munging - if you find yourself wanting ten replacements or pattern matching, you've outgrown this node and want something regex-capable from another pack.
How to install it
Comfyroll Studio (Suzie1 and RockOfFire) is a well-established utility pack with no model downloads and no heavy dependencies.
- ComfyUI Manager - search Comfyroll Studio, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git, then restart.
Also on CivitAI.
Common issues
The substitution logic is solid; the thing that actually breaks is the pack failing to import. When that happens you'll see Comfyroll Studio: Failed to load Graphics nodes / Failed to load Utility nodes in your log, capped with NameError: name 'CR_HalftoneGrid' is not defined. Ignore the NameError - it's a knock-on effect of a genuine import failure earlier in the startup log, almost always an incompatible Pillow version some other custom node pulled in. Comfyroll registers as one block, so that single bad import can take the whole pack down, Text Replace with it. Reinstall Pillow (pip install --upgrade --force-reinstall pillow) into ComfyUI's Python and restart. On the node itself, if a replacement "doesn't work," check your case and check for stray spaces in the find field - the match is exact.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | β | |
| find1opt | STRING | β | |
| replace1opt | STRING | β | |
| find2opt | STRING | β | |
| replace2opt | STRING | β | |
| find3opt | STRING | β | |
| replace3opt | STRING | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| STRING | * | β |
| show_help | STRING | β |