Sanitize Filename (Creepybits)
The Tiny Node That Stops Your Filenames from Exploding
- sanitized_text
If you've ever generated a filename from a prompt - say, feeding your positive prompt into a Save Image node's filename field - you've hit the wall: prompts are full of commas, colons, question marks, and line breaks, and half of those characters are illegal in filenames on Windows. This node takes any string, strips the junk, and hands back something a filesystem will actually accept. It's five lines of code dressed up as a lifesaver, and it does exactly one job without pretending to do more.
It lives in the Creepybits utility category, part of the ComfyUI-Creepy_nodes pack, and it's the kind of small honest utility that pack is full of.
How it works
Three steps, all visible in the source:
- Newlines are removed entirely (you don't want a line break in a filename).
- A regex strips the Windows-illegal characters:
\ / * ? : " < > |. - The string is trimmed of leading and trailing whitespace.
That's the whole mechanism. Nothing clever, nothing that'll surprise you - which is the correct behavior for a sanitizer.
The input and output
- text - the raw string you want cleaned, a multiline text box so you can paste in a full prompt.
- Output: sanitized_text - the cleaned version.
Wire it in front of any node that takes a filename string: Save Image filename fields, the Creepybits Save Raw Latent node, or a custom saver. One string in, one string out.
Installing it
It ships with ComfyUI-Creepy_nodes, so you install the whole suite:
cd ComfyUI/custom_nodes
git clone https://github.com/Creepybits/ComfyUI-Creepy_nodes
restart, done. Or search "Creepy_nodes" in ComfyUI Manager. No models, no heavy dependencies for this one.
Where it bites
Two things to keep straight. First, this is a filename sanitizer, not a path sanitizer - it deliberately strips slashes, so don't feed it "output/images/mypic" and expect a folder path to survive. Second, it imposes no length limit, so a genuinely huge prompt could still produce an obnoxiously long filename; trim that separately if it matters. And there's no deduplication or collision handling - two different prompts that sanitize to the same string will still collide on disk. For a tiny utility, that's a fair trade; it solves the "save failed because of a colon" problem and leaves the rest to you.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| sanitized_text | STRING | — |