Strip Model Extension
The One-String Utility Your Filename Templates Were Missing
- clean_text
Sometimes a node is so small it almost doesn't deserve a page. StripModelExtension is that node - one input, one output, one job: take my-model.safetensors and hand you back my-model.
It ships in the comfyui-save-image-organized pack as the quiet companion to Save Image Organized. Loader nodes give you model names with the file extension attached, and every time you want to turn flux2-klein-9b-Q5_K_M.gguf into a clean folder or filename, you're stuck reaching for a "text manipulation" node that wants you to write a regex. This is the no-regex option: feed it the string, get the clean name out.
How it works
It's blunt on purpose. The node checks the end of your string against a fixed list of known model extensions - .safetensors, .gguf, .ckpt, .pt, .pth, .bin, .onnx - and if the text ends with one, it chops that off (case-insensitively, and only one). No other part of the string changes, and if nothing matches, the text passes through untouched. It doesn't parse paths, doesn't touch the basename specifically - it operates on the whole string as-is.
The practical upshot: my-model.safetensors → my-model, and C:/models/flux/realism.gguf → C:/models/flux/realism. Whatever you hand it, the extension you don't want comes off.
Input and output
The whole thing fits in one line: text (a STRING) in, clean_text (a STRING) out. You can't get it wrong. It has no other parameters, no enums, no hidden gotchas.
What you do with it is the interesting part. It's a generic string utility, so wire clean_text into any STRING input - a filename template node, a folder-path generator, a text display so you can eyeball what your loaders are actually using. In the save-image-organized pack it pairs naturally with Save Image Organized's template variables: clean the loader's name once, feed it into a custom layout, and your folders stop carrying .safetensors baggage. It also works fine as a standalone debug tool to confirm which exact file a loader resolved.
Install
Same pack, same light footprint - the install only pulls numpy and Pillow, no model files, no heavy dependencies:
comfy node install save-image-organized
or clone it manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Delcado19/comfyui-save-image-organized
pip install -r comfyui-save-image-organized/requirements.txt
Then restart ComfyUI. The node appears as "Strip Model Extension" under utils/filename.
The two things to remember
- It only strips the known list. An exotic extension (
.binis covered, but say.npz) passes through unchanged. Check the list before you assume. - It strips from the whole string, not a basename. That's usually exactly what you want, but if you were hoping for path parsing, this isn't it.
There are beefier string tools out there - format-string utilities, regex helpers, text routers. For the narrow job of cleaning a model filename before you use it in a path, this one does it in one node with zero configuration. It's not going to change your life; it's going to stop one tiny annoyance from taking five minutes of your time.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Text to clean. Removes one known model file extension from the end, for example '.safetensors' or '.gguf'. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| clean_text | STRING | The input text with one known model file extension removed. |