Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > Sage Utils > Text Substitution

ComfyUI Node: Text Substitution

Class Name

Sage_TextSubstitution

Category
Sage Utils/text
Author
arcum42 (Account age: 6442days)
Extension
Sage Utils
Latest Updated
2026-05-17
Github Stars
0.03K

How to Install Sage Utils

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

Text Substitution Description

Facilitates dynamic text customization by replacing placeholders with specified values.

Text Substitution:

The Sage_TextSubstitution node is designed to facilitate dynamic text manipulation by allowing you to substitute placeholders within a given text template with specified values. This node is particularly useful for generating customized text outputs based on variable inputs, making it a powerful tool for creating dynamic and personalized content. By leveraging a flexible placeholder system, you can easily replace parts of a text with corresponding values from a dictionary, ensuring that your text outputs are tailored to specific needs or contexts. The node also provides options to handle missing placeholders gracefully and to add prefixes or suffixes to the final output, enhancing its versatility and adaptability in various text processing scenarios.

Text Substitution Input Parameters:

text

This parameter represents the template text containing placeholders that you want to substitute with actual values. The placeholders are defined using a specific delimiter, and the text serves as the base structure for the substitution process. There is no explicit minimum or maximum value for this parameter, but it should be a valid string containing the placeholders you intend to replace.

delimiter

The delimiter is a character or string used to identify placeholders within the template text. By default, the delimiter is set to $, but you can customize it to suit your needs. This parameter is crucial as it defines how placeholders are recognized and replaced within the text.

prefix

The prefix parameter allows you to add a specific string at the beginning of the final substituted text. This can be useful for adding consistent introductory text or formatting to your output. If not specified, the default value is an empty string.

suffix

Similar to the prefix, the suffix parameter lets you append a specific string to the end of the final substituted text. This is helpful for adding closing remarks or formatting to your output. The default value is an empty string if not provided.

strings

This parameter is a dictionary containing key-value pairs where the keys correspond to the placeholders in the template text, and the values are the actual strings to substitute. The keys should start with str_ to be recognized as valid inputs for substitution. This parameter is essential for defining the dynamic content that will replace the placeholders in the template.

Text Substitution Output Parameters:

result

The result parameter is the final output string after all specified substitutions have been made. It reflects the template text with placeholders replaced by their corresponding values from the strings dictionary, along with any specified prefix or suffix. This output is crucial as it represents the customized and dynamically generated text based on the input parameters.

Text Substitution Usage Tips:

  • Ensure that your template text is well-structured with clearly defined placeholders using the chosen delimiter to avoid substitution errors.
  • Use the strings parameter effectively by providing a comprehensive dictionary of key-value pairs to achieve the desired text customization.
  • Experiment with different delimiters if you encounter conflicts with existing characters in your template text to ensure smooth substitution.

Text Substitution Common Errors and Solutions:

ValueError

  • Explanation: This error may occur if there are invalid placeholders in the template text, possibly due to delimiter conflicts.
  • Solution: Verify that the placeholders in your template text are correctly formatted and match the specified delimiter. Consider changing the delimiter if conflicts persist.

KeyError

  • Explanation: This error arises when a placeholder in the template text does not have a corresponding key in the strings dictionary.
  • Solution: Ensure that all placeholders in the template text have matching keys in the strings dictionary. Use the safe_substitute method to leave unmatched placeholders as-is if necessary.

Text Substitution Related Nodes

Go back to the extension to check out more related nodes.
Sage Utils
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.