💀Prompts Any To String
The cleanup node that turns anything in your graph into a string
- text
💀Prompts Any To String is the Swiss-army text cleaner of the ComfyUI-PromptsO pack: you feed it a string, an integer, or a float, and it hands back a string - with a formatting pipeline (whitespace, case, special characters, prefix/suffix, and a free-form Python expression) applied along the way. If you've ever had a node output a number you needed as text, or a string with stray newlines that wrecked a prompt, this is the one that sorts it out before it reaches your encoder.
It lives in the pack's 💀 PromptsO category alongside Prompts Input, Combine, Split, and Replace - all single-author work from S4MUEL. One install (Manager, search "PromptsO", or a git clone) gets you all twelve nodes.
How it works
Everything here is optional - the node's required inputs are literally empty. You connect whichever of string_input, int_input, or float_input you actually have. It picks the first one that's connected, converts it to text (lists and dicts become comma-separated items, everything else gets a sensible str()), and then runs your transforms in a fixed order: expression first, then case, then special-character removal, then whitespace, then prefix and suffix are glued on.
The expression field is the interesting one. It's a Python expression evaluated with your text available as value - so something like value.replace("girl", "man") or value.upper().strip() just works. The sandbox is locked down to a small allowlist (len, str, int, round, max, min, sum, and friends - no open, no import), so it's not a security hole, just a handy mini-language. If the expression errors, the node throws a clear message at you and stops, which is the right failure mode.
The inputs that matter
string_input/int_input/float_input- the three source sockets; only the first connected one is used.remove_whitespace- a dropdown: None, All, Leading/Trailing, or Extra Spaces (the last collapses repeated spaces and newlines).remove_special_chars- strips everything except letters, digits, and spaces.lowercase/uppercase- toggle both and it quietly does lowercase.prefix/suffix- literal text added to the ends.expression- the Pythonvalue-based transform described above.
Output: a single text (STRING) that plugs into any string input, like a CLIP Text Encode or a Prompts Combine socket.
Install
cd ComfyUI/custom_nodes/
git clone https://github.com/S4MUEL-404/ComfyUI-PromptsO.git
cd ComfyUI-PromptsO
pip install -r requirements.txt
Restart ComfyUI afterward. The requirements file is heavy (torch, transformers, the Janus repo) because of the pack's local vision node - overkill for this one, but it's a shared install.
Common issues
- "Expression evaluation error" - the
valuevariable is your text; if you wrotetext.upper()it fails, because the variable is namedvalue. - Both case toggles on - it applies lowercase and warns you in the console. Pick one.
- Output is empty - nothing was connected, or the connected input was already empty. It returns
""rather than erroring, which is polite but easy to miss.
Reach for it when the default "convert to string" behavior of ComfyUI leaves you with a noisy string you'd rather not regex by hand. For a thin utility node, it covers a surprising amount of ground.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| string_inputopt | STRING | String input to convert | |
| int_inputopt | INT | Integer input to convert | |
| float_inputopt | FLOAT | Float input to convert | |
| remove_whitespaceopt | COMBO | None | Remove whitespace from output |
| remove_special_charsopt | BOOLEAN | false | Remove special characters (keep only alphanumeric and spaces) |
| lowercaseopt | BOOLEAN | false | Convert output to lowercase |
| uppercaseopt | BOOLEAN | false | Convert output to uppercase |
| prefixopt | STRING | Text to add at the beginning | |
| suffixopt | STRING | Text to add at the end | |
| expressionopt | STRING | Python expression to evaluate (use 'value' as the input variable) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |