Prompt To FileName
Name your output files after the prompt that made them
- filename
ComfyUI's default SaveImage names files ComfyUI_00001_.png, ComfyUI_00002_.png, and so on. Fine if you're generating a handful. A nightmare if you're making a few hundred variations and want to find the one with "red dress" in it without opening every file. Prompt To FileName turns your prompt into a filesystem-safe filename so the name itself tells you what's inside.
It's a pure string utility: prompt in, filename string out. No model, no network, nothing to tune beyond a template.
How it works
The node has a small template language with two placeholders, and the default template is the sensible one:
%time- replaced by the current time, formatted per thetime_formatinput (default%Y%m%d%H%M%S, i.e.20260827153045).%prompt- replaced by the cleaned-up prompt text.
So the default file_name_format of %time-%prompt produces something like 20260827153045-1girl,red dress,outdoor.png (minus the extension, which your save node adds).
Before substitution the prompt is sanitized, and the sanitizer is where the thought went in. Commas are stripped to spaces (you don't want a filename with no spaces and a wall of commas), and every character that's illegal in a filename on at least one OS - \ / : * ? " < > | plus newlines, tabs, and carriage returns - is replaced with an underscore. That's the bit that saves you the "save failed, invalid character" dance on Windows, where : and ? are outright banned.
Inputs and outputs
Four inputs:
prompt- your prompt string, wired in.file_name_format- the template with%time/%prompt. This is the one you'll actually touch, e.g.%prompt-%timeif you prefer prompt-first names.time_format- strftime syntax for the%timepart.max_length- total filename length cap, default 175 (that's the old filesystem path-component limit on Windows; you rarely need to change it). If the built name exceeds it, it's truncated from the end.
Output: a single filename string.
How you wire it
The natural home is a save node's filename. Core SaveImage has a filename_prefix widget you can convert to an input (right-click → Convert widget to input), then plug this node's output in. A little flow trick: because %time captures the moment the node runs, and save nodes run at the end of the graph, the timestamp reflects when the file was actually written, not when you queued the run. That makes %time-%prompt a solid default for keeping batches sorted.
Install
Standard pack install - ComfyUI Manager (search "ComfyUI-GadgetNodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/2daadv/ComfyUI-GadgetNodes.git
pip install -r ComfyUI-GadgetNodes/requirements.txt
Restart, and it's under Gadget/prompt.
The honest caveats
- Long prompts get truncated, and truncation is dumb. It cuts the string at
max_lengthfrom the right, which means a long prompt can lose its last tags mid-word. Keepmax_lengthgenerous (or your prompts short) and it rarely bites. - It dedupes nothing. Two runs a second apart with the same prompt collide; your save node's counter suffix is what disambiguates them, if it has one.
- Filenames are cosmetic anyway. The actual prompt always lives inside the PNG metadata (the workflow chunk), so a truncated filename costs you nothing except findability. This node is purely about that findability.
A modest node, honestly - but if you batch-generate and you're tired of guessing which output file is which, it earns its slot in the graph.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| file_name_format | STRING | %time-%prompt | — |
| time_format | STRING | %Y%m%d%H%M%S | — |
| max_length | INT | 17520–260 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| filename | STRING | — |