Save Text
Save any text to a file without a code node
- filepath
Sometimes the point of a workflow isn't the image - it's the text. You've got a prompt, a set of LoRA keywords, or a metadata dump you want to keep, and instead of screenshotting a preview node, you'd rather have an actual .txt file in your output folder. That's this node. It writes whatever string you feed it to disk and tells you where it went, which is a surprisingly useful thing to have as a proper node instead of a Python script.
How it works
Four inputs: text (the content to save), filename_prefix (default ComfyUI_Text), file_extension (default txt), and batch_size (default 1). Run the node and it writes the text to a file in ComfyUI's output directory with an auto-incrementing counter - so the first save is ComfyUI_Text_00001.txt, the next ComfyUI_Text_00002.txt, and so on. It never overwrites; it scans for the highest existing counter and goes one higher.
The filename_prefix is where it gets fun. You can put date placeholders in it - %year%, %month%, %day%, %hour%, %minute%, %second% - so prompts/%year%-%month%-%day% becomes a dated subfolder, and the tooltip also accepts the %date:yyyy-MM-dd% style formatting. You can also put a path in the prefix (logs/my_run) and the node creates the subfolder for you - as long as it stays inside the output directory, which it enforces. And the batch_size input controls how many counter-incremented files it writes (loop over the same text N times, effectively).
The single output is filepath - a string with the full path of the file it just wrote. Wire that into a display node or a downstream step that needs to know where the file lives.
What it's actually for
The most common use is dumping metadata or prompt text that you want to keep alongside your images - save your A1111-style parameters to a .txt, or export a batch of generated prompts to review later. If you're doing a batch run and want one prompt file per image, hooking this up with %second% in the name (or bumping batch_size) gives you uniquely-named files without collisions.
Installing it
It's part of Sage Utils. ComfyUI Manager (search Sage Utils) or:
cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils
cd ComfyUI_SageUtils
pip install -r requirements.txt
Restart ComfyUI. The only pip dependency is dynamicprompts; no models required.
The gotchas
The node refuses to write outside the output folder - that's a deliberate safety guard, not a bug, so ../ tricks won't work. And if you're feeding it text from a Set Text node, remember the file is written every time the node executes, which means every queue run adds another file. On a batch that's what you usually want, but if it's not, gate the node or accept the clutter.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| filename_prefix | STRING | ComfyUI_Text | The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% to include values from nodes. |
| file_extension | STRING | txt | The file extension to use for the saved file. |
| text | STRING | The text to save to a file. | |
| batch_size | INT | 1 | The number of files to save. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| filepath | STRING | Output value for filepath. |