Nodes/ComfyUI Deploy/String Function
ComfyUI Node

String Function

String Function is really a prompt-tag cleaner wearing two hats

By BennyKok·Created 3 years ago·Updated 9 months ago· 1,529
String Function
    • STRING
    ◄action▾►
    ◄tidy_tags▾►
    ◄text_a—►
    ◄text_b—►
    ◄text_c—►

    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 - append or replace. Required, and it decides which half of this node you get.
    • tidy_tags - yes or no. Leave it on.
    • text_a, text_b, text_c - all optional multiline strings. In append mode they're the pieces; in replace mode text_a is the haystack, text_b is the needle (or /regex/), text_c is 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.

    Category🔗ComfyDeploy

    Inputs (5)

    NameTypeDefaultDescription
    actionCOMBO2 options: append, replace
    tidy_tagsCOMBO2 options: yes, no
    text_aoptSTRING—
    text_boptSTRING—
    text_coptSTRING—

    Outputs (1)

    NameTypeDescription
    STRINGSTRING—