Text Operations

In ComfyUI, text mostly shows up as prompts. Automating a few operations, like replacing part of a string or adding trigger words to a prompt an LLM wrote, makes your workflows more convenient.
What is a string?
In programming, text is called a string to tell it apart from numbers and other data.
apple→ 5-character string123→ Looks like a number, but is actually a string treated as text" "(Space) → Invisible, but a 1-character string
Basic Operation Nodes
String Node (Text Input)

The basic node for entering a string. Use the String (Multiline) node to enter text with line breaks.
Concatenate Node (Text Joining)

Combines multiple strings into one.
(Example: apple + pen → applepen)
delimiteris the separator. You can use anything you like (a comma, a line break, etc.).
Format Text Node

This node lets you create a text template and insert other strings into it.
It can combine text more flexibly than Concatenate.
For example, if you connect apple to a and red to b, then write {a} is {b}. in format, it creates a string like apple is red..
Replace Node (Text Replacement)

Replaces the specified text with other text.
(Example: apple pen → orange pen)
Substring Node (Text Extraction)

Extracts the characters in a specified range.
(Example: apple → ppl)
- Cuts out the characters from position
startto positionend.
Trim Text Node (Remove Spaces)

Removes spaces at the start and end of a string.
(Example: apple → apple)
- Unglamorous but important: it prevents errors from stray spaces in things like user input.
Length Node (Character Count)

Counts the length of the text.
(Example: apple → 5)
- Spaces and line breaks are also counted as 1 character.
- The output is an int (number).
Advanced Operations (Regular Expressions)
These use a pattern syntax called regular expressions (Regex) for more complex searching and replacing.
Regex Extract Node

Uses a regular expression to extract matching text.
Regex Replace Node

Uses a regular expression to replace matching text.
Power Puter (rgthree)
The Power Puter from rgthree-comfy that came up in Simple Math can take and output strings too, so you can handle text flexibly, including everything covered above.
