Nodes/ComfyUI-PromptsO/💀Prompts Any To String
ComfyUI Node

💀Prompts Any To String

The cleanup node that turns anything in your graph into a string

By S4MUEL-404·Created 11 months ago·Updated 10 months ago· 3
💀Prompts Any To String
    • text
    string_input
    int_input
    float_input
    remove_whitespaceNone
    remove_special_charsfalse
    lowercasefalse
    uppercasefalse
    prefix
    suffix
    expression

    💀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 Python value-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 value variable is your text; if you wrote text.upper() it fails, because the variable is named value.
    • 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.

    Category💀PromptsO

    Inputs (10)

    NameTypeDefaultDescription
    string_inputoptSTRINGString input to convert
    int_inputoptINTInteger input to convert
    float_inputoptFLOATFloat input to convert
    remove_whitespaceoptCOMBONoneRemove whitespace from output
    remove_special_charsoptBOOLEANfalseRemove special characters (keep only alphanumeric and spaces)
    lowercaseoptBOOLEANfalseConvert output to lowercase
    uppercaseoptBOOLEANfalseConvert output to uppercase
    prefixoptSTRINGText to add at the beginning
    suffixoptSTRINGText to add at the end
    expressionoptSTRINGPython expression to evaluate (use 'value' as the input variable)

    Outputs (1)

    NameTypeDescription
    textSTRING