ComfyUI Node: replace

Class Name

Basic data handling: StringReplace

Category
Basic/STRING
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling 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

replace Description

The `StringReplace` node enables efficient substring replacement in text, with optional limits on occurrences.

replace:

The StringReplace node is designed to facilitate the replacement of specific substrings within a given string with new substrings. This node is particularly useful for text manipulation tasks where you need to modify parts of a string efficiently. By allowing you to specify both the substring to be replaced and the new substring, it provides a straightforward method to update text content dynamically. Additionally, the node offers an optional parameter to limit the number of replacements, giving you control over how many occurrences are altered. This functionality is essential for tasks that require precise text editing, such as formatting, data cleaning, or preparing text for further processing.

replace Input Parameters:

string

This parameter represents the original string in which you want to perform the replacement. It is the main text that will be searched for occurrences of the specified substring. The default value is an empty string, and there are no minimum or maximum length constraints.

old

The old parameter specifies the substring that you want to replace within the original string. It is crucial for identifying the parts of the string that need to be changed. The default value is an empty string, meaning no specific substring is targeted unless specified.

new

This parameter defines the new substring that will replace each occurrence of the old substring in the original string. It allows you to update the text with the desired content. The default value is an empty string, which effectively removes the old substring if no new content is provided.

count

The count parameter is optional and determines the maximum number of occurrences to replace. If set to a positive integer, only that many occurrences of the old substring will be replaced. The default value is -1, which indicates that all occurrences should be replaced. The minimum value is -1, and there is no explicit maximum value.

replace Output Parameters:

string

The output is a modified version of the original string, where the specified occurrences of the old substring have been replaced with the new substring. This output reflects the changes made according to the parameters provided, allowing you to see the result of the replacement operation.

replace Usage Tips:

  • Use the count parameter to limit replacements when you only want to change a specific number of occurrences, which can be useful for tasks like updating only the first few instances of a substring.
  • Ensure that the old substring is correctly specified to avoid unintended replacements, especially in cases where the substring might appear multiple times in different contexts.

replace Common Errors and Solutions:

Empty old substring

  • Explanation: If the old substring is empty, the node may not perform any replacements as there is no target substring specified.
  • Solution: Ensure that the old parameter is set to a valid substring that you intend to replace.

No occurrences found

  • Explanation: If the old substring does not exist in the original string, no replacements will occur, and the output will be identical to the input string.
  • Solution: Double-check the old substring to ensure it matches the part of the string you want to replace. Consider using case-insensitive matching if needed.

replace Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
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.

replace