ComfyUI > Nodes > ComfyUI_StringEssentials > String Multi Replace

ComfyUI Node: String Multi Replace

Class Name

StringMultiReplace

Category
utils/StringEssentials
Author
bradsec (Account age: 4314days)
Extension
ComfyUI_StringEssentials
Latest Updated
2026-03-09
Github Stars
0.03K

How to Install ComfyUI_StringEssentials

Install this extension via the ComfyUI Manager by searching for ComfyUI_StringEssentials
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI_StringEssentials in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

String Multi Replace Description

StringMultiReplace node automates multiple substring replacements in text, supporting case sensitivity and punctuation preservation.

String Multi Replace:

The StringMultiReplace node is a powerful utility designed to facilitate the process of replacing multiple substrings within a given text. This node is particularly beneficial for AI artists and developers who need to automate text manipulation tasks, such as cleaning up text data or preparing strings for further processing. By allowing you to define multiple replacement pairs, the node can efficiently transform an input string according to your specifications. It supports advanced features like case sensitivity, whole string matching, and punctuation preservation, making it versatile for various text processing needs. The node's ability to handle complex replacement scenarios with ease and precision makes it an essential tool for anyone working with text data in creative or technical projects.

String Multi Replace Input Parameters:

input_string

This parameter represents the string that you want to process. It is the primary input for the node, and all specified replacements will be applied to this string. There is no default value, and it must be provided for the node to function.

replacement_pairs

This parameter allows you to specify the pairs of strings that you want to replace and their corresponding replacements. Each pair should be entered on a new line in the format searchreplace. The default delimiter is a colon (:), but this can be customized. This parameter supports multiline input, enabling you to define multiple replacements at once.

replacement_delimiter

This parameter defines the character(s) that separate the search and replace strings in the replacement_pairs. The default value is two colons (::). Adjusting this delimiter allows you to use different characters to separate your search and replace terms, which can be useful if your text contains colons.

match_case

This boolean parameter determines whether the search should be case-sensitive. By default, it is set to False, meaning the search is case-insensitive. Enabling this option (True) will ensure that only exact case matches are replaced.

match_whole_string

This boolean parameter specifies whether the node should match whole strings only. When enabled (True), the node will only replace exact matches of the search string, ignoring partial matches. The default setting is False.

preserve_punctuation

This boolean parameter controls whether punctuation marks adjacent to matched text should be preserved. By default, it is enabled (True), ensuring that punctuation is not removed during replacements. Disabling this option (False) will allow punctuation to be removed if it follows a matched string.

remove_extra_spaces

This boolean parameter, enabled by default (True), ensures that extra spaces are removed from the resulting string after replacements. It helps in cleaning up the text by normalizing spaces and removing unnecessary whitespace.

String Multi Replace Output Parameters:

modified_string

This output parameter provides the final string after all specified replacements have been applied. It reflects the transformed version of the input_string, incorporating all changes defined by the replacement_pairs and other input parameters. This output is crucial for verifying the effectiveness of the replacements and for further use in your text processing workflow.

String Multi Replace Usage Tips:

  • Use the replacement_pairs parameter to define all your replacements in one go, ensuring each pair is on a new line for clarity and organization.
  • Enable match_case if you need precise replacements that respect the case of the text, which is useful for case-sensitive data.
  • Utilize preserve_punctuation to maintain the integrity of your text's punctuation, especially when working with natural language data.

String Multi Replace Common Errors and Solutions:

Missing replacement delimiter in replacement_pairs

  • Explanation: This error occurs when a line in the replacement_pairs does not contain the specified replacement_delimiter.
  • Solution: Ensure that each line in the replacement_pairs includes the delimiter to separate the search and replace strings.

Empty search string in replacement_pairs

  • Explanation: This error happens when a search string is empty, which can lead to unintended replacements.
  • Solution: Verify that each search string in the replacement_pairs is not empty before processing.

Invalid regular expression pattern

  • Explanation: This error might occur if the search string contains characters that are interpreted as part of a regular expression.
  • Solution: Use the replacement_delimiter to escape special characters or ensure that the preserve_punctuation option is set appropriately to handle such cases.

String Multi Replace Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI_StringEssentials
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.