String Function
String Function is really a prompt-tag cleaner wearing two hats
- STRING
The name says "String Function," but what you actually get from this node is a prompt-tag combiner and a find-and-replace tool bolted into one box. It ships inside the ComfyUI Deploy pack (the 🔗ComfyDeploy category), and its real job is letting a deployed workflow stitch together a prompt from a few pieces - or scrub one clean - before it hits the CLIP encoder.
Why it exists makes sense once you've deployed a workflow. When you hand a txt2img API to other people, they want to send you a prompt string, not rebuild your graph. String Function is how you let a caller's tags merge with the baked-in style tags your workflow needs, with tidy_tags cleaning up the mess afterwards. You'll usually find it sitting right before a CLIPTextEncode in deployed SDXL or Flux pipelines.
How it works
The mechanism is simpler than the two-hat framing suggests. Set action to append and it joins text_a, text_b, and text_c with ", " (or nothing, if tidy_tags is off). Set it to replace and it does literal find-and-replace on text_a - unless text_b starts and ends with /, in which case it treats it as a regex and substitutes matches with text_c.
The tidy_tags toggle is the sleeper feature. It collapses double spaces, strips stray commas, kills duplicated commas, and trims whitespace. For tag-heavy anime workflows this is genuinely the difference between cat, , hat, blue,, sky and cat, hat, blue, sky - the kind of cleanup that quietly improves your sampling, because a junk-padded prompt is a drift-padded prompt.
The inputs that matter
action-appendorreplace. Required, and it decides which half of this node you get.tidy_tags-yesorno. Leave it on.text_a,text_b,text_c- all optional multiline strings. In append mode they're the pieces; in replace modetext_ais the haystack,text_bis the needle (or/regex/),text_cis the replacement.
Output is a single STRING. Despite being marked as an output node in the schema, it still returns a result value, so you can wire it straight into a CLIPTextEncode or a text-prompt node.
Installing it
It's part of ComfyUI Deploy, so the install is the pack install. Either search "ComfyUI Deploy" in ComfyUI Manager, or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/BennyKok/comfyui-deploy.git
Restart ComfyUI after cloning. The pack pulls in a few pip deps (aiofiles, pydantic, opencv-python, imageio-ffmpeg, brotli, tabulate) - opencv is the chunky one, so first load can take a minute. No model files, no API key, no extra downloads. It works fine as a plain string utility even if you never touch the ComfyDeploy dashboard.
Where people get burned
Nothing dramatic here, just one trap: if you leave text_a, text_b, or text_c empty in append mode, the empty strings are filtered out, which is usually what you want - but in replace mode an empty text_b turns into .replace("", ...) behavior that inserts text_c everywhere. Weird, but predictable. And remember this node is the string prep stage, not the prompt node itself - people reach for it expecting a prompt-weight control and find only text out. It outputs plain text; the weighting happens downstream in your text encoder.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| action | COMBO | 2 options: append, replace | |
| tidy_tags | COMBO | 2 options: yes, no | |
| text_aopt | STRING | — | |
| text_bopt | STRING | — | |
| text_copt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |