Nodes/ComfyUI-Ollama-Describer/πŸ“ Text Transformer πŸ“
ComfyUI Node

πŸ“ Text Transformer πŸ“

Prepend, append, and find/replace on a text string

By alisson-anjosΒ·Created 2 years agoΒ·Updated 5 months agoΒ· 123
πŸ“ Text Transformer πŸ“
    • text
    β—„textβ–Ί
    β—„prepend_textβ–Ί
    β—„append_textβ–Ί
    β—„replace_find_modeβ–Ύβ–Ί
    β—„replace_findβ–Ί
    β—„replace_withβ–Ί

    The unglamorous but genuinely useful node that saves you from writing a Python node just to fix up text. It takes a string and lets you prepend something, append something, and find-and-replace part of it - three operations, one node, done. It shows up most often right after one of the pack's LLM nodes, cleaning up a raw result before it goes anywhere else in the graph.

    A common real case: OllamaImageDescriber hands you a full description like "The image shows a woman standing in a forest..." but your CLIPTextEncode wants a comma-separated tag style instead. Rather than rewriting the model's prompt and hoping it listens better, you run the output through this node and strip or swap what doesn't fit.

    How it works

    It applies its operations in a fixed order - prepend, then append, then find/replace - against whatever string arrives on text. The find/replace step can run in two modes, controlled by replace_find_mode: plain literal string matching, or full regular expressions if you need pattern-based replacement instead of an exact substring.

    The inputs and outputs that matter

    • text - the required input, the string being transformed. Almost always wired from an upstream node's output rather than typed by hand.
    • prepend_text / append_text (both optional) - text glued onto the front or back of text. A classic use is bolting on a fixed trigger word or style tag that you always want present regardless of what the LLM generated.
    • replace_find_mode - normal for a literal substring match, or regular expression (regex) if you need something more powerful, like stripping any instance of a pattern rather than one exact phrase.
    • replace_find / replace_with - the substring (or regex pattern) to look for, and what to swap it with. Leave replace_with empty to just delete whatever replace_find matches.

    Output is a single text STRING - chain it into a CLIPTextEncode, a Save Text node, or another Text Transformer if you need more than one pass of cleanup.

    How to install it

    Bundled with the rest of the pack - no separate install or model needed, since this node does no LLM calling of its own. Via ComfyUI Manager, search "ComfyUI-Ollama-Describer" and install. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alisson-anjos/ComfyUI-Ollama-Describer.git
    pip install -r requirements.txt   # or install.bat on Windows
    

    Restart ComfyUI. This node runs entirely locally and instantly - no Ollama connection required for it specifically, even though it's usually used right after a node that does need one.

    Common issues & troubleshooting

    The most common surprise is regex mode behaving unexpectedly if you meant literal mode - regex special characters (., *, (, ), and so on) mean something different than their plain-text selves once replace_find_mode is switched to regex, so a replace_find value that worked as a literal string can silently match too much or too little once you flip that toggle. If nothing seems to change, double-check replace_find actually matches the text exactly as the upstream node produced it - LLM output is inconsistent about capitalization and punctuation between runs, so a find string that matched once may not match the next generation. For anything beyond a single exact phrase or a simple pattern, that inconsistency is usually the argument for reaching for regex mode in the first place.

    CategoryOllama

    Inputs (6)

    NameTypeDefaultDescription
    textSTRINGβ€”
    prepend_textoptSTRINGβ€”
    append_textoptSTRINGβ€”
    replace_find_modeoptCOMBO2 options: normal, regular expression (regex)
    replace_findoptSTRINGβ€”
    replace_withoptSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    textSTRINGβ€”