Nodes/comfyui-mdsnodes/Convert to String
ComfyUI Node

Convert to String

Turn anything into text with Convert to String (MarCStr)

By MarwanDSAI·Created 20 days ago·Updated about 23 hours ago· 1
Convert to String
  • any_input
  • string

ComfyUI is aggressively typed. A widget that wants a STRING will refuse a wire from a number node, and the combo boxes that hand you model filenames don't always want to talk to the text box you have in mind. Convert to String (class name MarCStr) is the duct tape for exactly that situation: one input that accepts literally anything, one text output. It's the node you drop in when the error message says "don't know how to convert" and you'd rather not rewrite your whole graph.

It's dead simple under the hood. The single input is a wildcard (*) - in ComfyUI's type system that means "accept any socket type," the same escape hatch that makes switch and logic nodes possible. The node just calls Python's str() on whatever arrives and hands back the result as a STRING. Feed it an INT and you get "123", a FLOAT becomes "1.5", a combo selection becomes the filename it was holding, and None (a disconnected or empty input) quietly becomes "" instead of crashing. The author's tooltip on the input says it all: "Connect any data type (INT, FLOAT, COMBO, MODEL, etc.) here."

The one thing worth being blunt about: str() on a model object does not give you a model name. If you wire a MODEL socket into this node you get something like <module.MyNode object at 0x7f...> - a memory address, totally useless. If you want the filename of a checkpoint or ControlNet, use the pack's own selector nodes (Select Diffusion Model, ControlNet Select), which output clean filename strings, and run those into Convert to String. Same for latents and images: their string forms are garbage, so don't bother.

So where does it actually shine? Building filename prefixes, for one. SaveImage's filename_prefix accepts a live value from another node, and after a couple of conversions you can end up with a number you want inside the filename - Convert to String is the bridge. It's also handy for feeding a text node you want to read the result of, or as the front end of a string-joining chain where you can finally wire anything into a STRING socket.

It ships in comfyui-mdsnodes, a small utility pack built to support the author's "Ultimate Model Tester Workflow" on Civitai. The pack has no extra dependencies - its requirements.txt is empty - so it installs in seconds. In ComfyUI Manager search for ComfyUI-MDSNodes and hit Install, then restart ComfyUI; or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/MarwanDSAI/comfyui-mdsnodes

Then restart ComfyUI. It'll show up under MDSNodes → Text as "Convert to String."

Troubleshooting is mostly two symptoms. If the output is a garbage object address, you wired a model or latent in - swap to a filename-producing node. If it's blank, the input was None or empty, which is the node doing its job, not a bug. That's the whole thing. There's a lot of shiny machinery in ComfyUI; this is the boring node that makes the shiny stuff work together.

CategoryMDSNodes/text

Inputs (1)

NameTypeDefaultDescription
any_input*Connect any data type (INT, FLOAT, COMBO, MODEL, etc.) here.

Outputs (1)

NameTypeDescription
stringSTRINGThe input data converted into a clean text string.