Nodes/ComfyUI illumorae/Text To Filename Safe Text
ComfyUI Node

Text To Filename Safe Text

Turn a prompt into a filename before your save node mangles it

By CorvaeOboro·Created 8 months ago·Updated 5 days ago· 1
Text To Filename Safe Text
    • STRING
    string_in
    max_length150

    You want your saved images named after what's in them. But prompts contain commas, colons, slashes, emoji, and other characters that will make a save node either fail or produce a filename your OS refuses to open. Text To Filename Safe Text, from the illumorae pack (CorvaeOboro's text utilities), is the buffer in between: it takes any string and returns a Windows-safe, normalized, length-truncated version you can safely drop into a filename prefix.

    The "Windows-safe" part is doing real work. Windows reserves <>:"/\|?* and control characters, and it's the lowest common denominator across all the platforms people run ComfyUI on - sanitize for Windows and you're safe everywhere. This is the node that sits directly upstream of the pack's own Save Image Extended FolderPath and Save Animated WEBP FolderPath: feed it a subject name or a trimmed prompt, and your gen/ folder fills up with files like queen_aurora_sunset.png instead of output_001.png.

    How it works

    The processing, from the source: normalize the string with Unicode NFKD (so accented and composed characters collapse to their base forms), filter out the invalid filename characters, strip whitespace, drop non-printable control chars, and truncate to max_length if needed. What survives is boring ASCII-ish text that no filesystem will complain about.

    Inputs are the pair you'd expect:

    • string_in - the raw text.
    • max_length - default 150, hard max 250. Long prompts get cut to fit; pick your budget based on how much filename you can tolerate.

    Output is a single STRING with the safe text.

    Using it well

    The workflow trick: on your save node, right-click filename_prefixConvert widget to input, then wire this node's output in. Now the filename is derived from whatever you passed - a subject line, a trimmed prompt, a lora name. Pair it with Select ITEM By Amount Generated and your batch loop gets self-describing, project-organized output with zero manual naming. The NFKD normalization is a quiet win too: "café" becomes "cafe", so your filenames don't break on filesystems that hate non-ASCII.

    Installing it

    ComfyUI Manager → search "illumorae" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CorvaeOboro/ComfyUI_illumorae
    

    Restart. No models, no downloads.

    Troubleshooting

    If your filenames come out shorter than expected, your source text was longer than max_length - that's the truncation working as designed, so raise the limit or shorten the input. If something still saves weird, check whether your save node is applying its own sanitization on top (the pack's save nodes do), which can double-underscore things - harmless, just ugly. And don't expect it to keep a filename human-readable forever: it's a safety filter, not a caption generator. 150 characters of lora soup is technically a valid filename, but you'll never be able to read it.

    Categoryillumorae

    Inputs (2)

    NameTypeDefaultDescription
    string_inSTRING
    max_lengthINT1501–250

    Outputs (1)

    NameTypeDescription
    STRINGSTRING