DB Convert to String
Turn a data value into a string — or a filename you'd actually trust
- input
- output
Every DBGet* node in the DataBeast pack hands you back a string, but it's a string wearing a DB_ITEM costume. DBConvertToString is the node that strips the costume off and gives you a real STRING you can wire into a prompt, a text widget, or a filename - plus two lossy cleanup modes that exist because one of the most common things you'll do with batch data is name output files after it.
What it does
The node unwraps the incoming DBItem and stringifies it. Simple values become their string form; if the item is a dict or list - say you grabbed a whole row of your data - it gets serialized to a JSON string so nothing is lost.
- input - a
DB_ITEM, typically fromDBGetItem,DBGetBatchList, orDBLoadDatadirectly. - filesafe - a boolean. When true, it scrubs the string for use in a file path: non-alphanumeric characters collapse into single underscores, and leading/trailing junk gets stripped. The tooltip warns it's a lossy operation - it is, by design.
- shortenize - a boolean (the author jokes it's not a technical term). When true, the string is aggressively shortened: vowels removed, word starts capitalized, and long strings truncated and stamped with a short hash so they stay unique. Dicts and lists are handled per-string before being JSON'd.
The two flags combine, so filesafe + shortenize gives you a compact, path-safe name.
Why you'd actually reach for it
The killer use case is auto-naming outputs. Batch through a prompts file with DBGetBatchList, pull the prompt with DBGetItem, and you want each PNG saved with a name derived from that prompt - not ComfyUI_00001_. filesafe is the one flag that makes that work: "A puppy wearing a yellow hat" becomes A_puppy_wearing_a_yellow_hat instead of a path with spaces and punctuation that half your tools choke on. When filenames start colliding or getting too long, add shortenize to squeeze them down. It's also just the most convenient way to get a plain string out of a DBItem when you don't need any of the convert-to-number machinery.
Gotchas
- The default is plain stringify. If you expected a filename-safe output with both flags off, you'll get raw text with spaces and punctuation intact. Turn the flags on deliberately.
- Failures return an empty string. Like everything in this pack, exceptions are swallowed - a weird item type gives you
"", not an error. - Don't rely on it to round-trip numbers. If you want to do math, use
DBConvertToFloatorDBConvertToInt; this node is for display and naming, not computation.
Installing
It ships with ComfyUI DataBeast, which is not in ComfyUI Manager yet. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/hanoixan/ComfyUI-DataBeast
cd ComfyUI-DataBeast
pip install -r requirements.txt
Restart ComfyUI and the DB nodes show up under DataBeast. Only pyyaml and RestrictedPython are required - no models to download. If you built graphs against the V0.1 alpha, note that V0.2 reworked DBConvertToString (filesafe and shortenize are now separate toggles), so old nodes may need their settings reapplied.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input | DB_ITEM | Input from a DBGet* node. | |
| filesafe | BOOLEAN | If True, make it safe for use in file paths. This is a lossy operation that replaces non-alphanumeric characters with single _s | |
| shortenize | BOOLEAN | If True, shorten component strings severely by removing vowels and adding hash codes for long strings. Works on a per-string basis for deep data structures like dict. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | STRING | — |