To String | Basic
Turn Any ComfyUI Value Into Text (and Stop Fighting Your Prompts)
- any
- STRING
To String takes whatever you plug into it and hands you back the same value as plain text. That's the whole job, and it's one of those nodes you don't think you need until you're hand-typing a number into a prompt for the fifth time in a row.
Here's the thing about ComfyUI: the text you send to CLIP Text Encode is just a string, but half the values you actually care about - a seed, a denoise strength, a step count - live in the graph as numbers. To String is the glue that turns "42" the float into "42" the word so you can slot it into a sentence like "a portrait of subject ID {seed}". It's the conversion half of a small pack that also ships To Int, To Float, and To Bool, and it exists for the same reason the math nodes do: the core workflow has no built-in way to do this cleanly.
How it works
Mechanically it's one line of Python: str(any). The node's input is typed as * - an "any type" socket - which is a deliberately loose contract borrowed from pythongosssss's work in the ComfyUI frontend (the pack credits him in its base code). Loose means genuinely loose: wire in a number, a string, a boolean, even a model reference or a LORA stack, and it will happily stringify whatever arrives. The output is always a STRING.
That laziness is the whole point and also the trap. Python's str() doesn't clean up after you. Feed it 0.1 + 0.2 and you get "0.30000000000000004" - floats come out at full precision, and there is no rounding anywhere in this node. If you're building a prompt from a computed value, run it through a round (this same pack has Unary Math | Basic and Number Round | Basic) before To String, not after. Similarly, str(True) gives "True" with a capital T, which will break any downstream that expects lowercase true - API payloads and some JSON consumers are picky about that.
The one input and the one output
- any - accepts anything. There's nothing else to set; no options, no formatting controls. If you want zero-padding or fixed decimals, do it upstream.
- STRING - the text result. Wires straight into
CLIP Text Encode, text-concat/format nodes,Save Text-style outputs, or anything that takes aSTRINGsocket.
The output node's STRING type is ComfyUI's standard text type, so it plays nice with the ecosystem's text utilities rather than being an oddball custom type.
Installing it
Install it through ComfyUI Manager (search for ComfyUI-Basic-Math, the display prefix is "Basic Math ➕"), or clone it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
# then restart ComfyUI
No requirements file, no models to download, no CUDA dependencies - the whole pack imports only Python's standard library. It's about as clean an install as a custom node gets, which is nice in an ecosystem where the most common complaint (per the usual r/comfyui chorus) is installing missing nodes and fixing dependency conflicts 90% of the time.
When it bites
The failure mode is silent. If you stringify something exotic, str() doesn't error - it just gives you a repr like <tensor at 0x...>. You'll see that in the output box and wonder what happened. Nothing is broken; you just asked Python to render something it doesn't know how to render nicely. Keep To String pointed at numbers, strings, and booleans and you'll never see it. It's a boring node, and that's exactly why it's the one I reach for when a workflow keeps demanding text I don't feel like typing.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| any | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |