Nodes/ComfyUI-JNodes/Search And Replace From File
ComfyUI Node

Search And Replace From File

Run a whole file of trigger-word swaps at once

By JaredTherriault·Created 3 years ago·Updated about a month ago· 91
Search And Replace From File
    • STRING
    text
    replacements_file_path

    If you're maintaining a real list of trigger-word substitutions - every obfuscated embedding name you use, mapped to something readable, say - wiring up a dozen JNodes_SearchAndReplace nodes back to back is miserable. This node reads that whole list from one external text file instead: one pair per line, in the format the README specifies directly - 3mb3dd1n4->embedding - and applies every substitution to your text in a single pass.

    Because the mapping lives in a file rather than inside the graph itself, you can update your substitution list without touching the workflow at all - edit the file, save, and the next run picks up the change. That's genuinely useful if the same substitution list needs to apply across several different workflows, or if you want to version it separately from your graphs.

    How it works

    text is the full string to clean up. replacements_file_path points at a plain text file, one search->replace pair per line, using the -> separator shown in the README. The node reads the file, builds its substitution list from it, and applies every pair to text in one go, returning the result.

    The inputs and outputs

    • text (STRING, multiline) - the text to process.
    • replacements_file_path (STRING) - path to a file with one search->replace pair per line.
    • STRING output - the text with every substitution applied.

    How to install it

    Via ComfyUI Manager: Install Custom Nodes, search "JNodes", install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JaredTherriault/ComfyUI-JNodes
    pip install -r ComfyUI-JNodes/requirements.txt
    

    then restart ComfyUI. No model downloads - you just need to actually create the replacements file yourself; the node doesn't ship one.

    Common issues & troubleshooting

    Path not resolving. Same rule as any other file-path input in this pack: it's read from wherever the ComfyUI server process is running, not your local browser machine. If ComfyUI is containerized or remote, the path has to be valid on that machine, and a path that opens fine in your own file explorer may not exist there at all.

    Wrong separator or malformed lines silently skipped or misread. The format is specifically search->replace, no spaces documented around the arrow in the README's own example. If a line doesn't match that shape, don't assume it's being applied - verify with a short test file and a JNodes_PrintString or preview node before trusting a long production list.

    File not found because of a typo, and the node fails the whole run. Since every downstream node depends on this one's output, a bad path here breaks everything after it, not just the substitutions. If your workflow errors out immediately at this node, check the path first before assuming it's something more complicated.

    One substitution list applied everywhere, even where you didn't want it. Because this reads the whole file every time and applies every pair, it's an all-or-nothing tool - there's no way to selectively apply only some of the file's substitutions on a given run. If you need different substitution sets for different situations, keep separate files and swap the path, or fall back to JNodes_SearchAndReplaceFromList for something you want to edit inline per-workflow instead.

    Categorysd

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    replacements_file_pathSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING