EmAySee Save Text to File
Get that LLM output off the graph and onto disk as a .txt
ComfyUI will happily generate a thousand captions or prompts, but nothing core will write them to disk as plain text. This node fixes that: take any STRING, give it a filename, and it writes a .txt file - either into ComfyUI's output folder (with subfolder support) or to an absolute path if you hand it one. It's the companion every LLM/captioning workflow ends up needing.
How it works
Three inputs, all required:
- text_to_save (multiline) - the string that becomes the file's contents.
- filename (default
output_text) - the base name. Don't worry about the extension;.txtis added for you, and if you typenotes.txtit strips the.txtand re-adds it. - subfolder (default empty) - a subfolder under ComfyUI's output directory.
The path logic is the useful part: if filename is an absolute path it writes there directly; if subfolder starts with / or looks like a drive path (the C: check), it treats that as the directory; otherwise it joins output_dir + subfolder + filename. It creates directories as needed and sanitizes the filename (drops characters that aren't alphanumeric, space, dot, underscore, or dash), so a filename with slashes or weird symbols won't crash it - it just gets scrubbed.
No outputs; it's an output node.
Gotchas
- It overwrites. Same filename + same folder = previous file replaced. No counter. If you're logging per-run data, wire a timestamp or a seed into the filename or you'll only ever keep the last run.
- Sanitization is silent. A filename you think is fine can come out scrubbed (e.g., emoji or
:in the name get stripped). If you find files with slightly different names than you typed, that's why. - The
output_textdefault is a trap in a long batch - fifty runs all write tooutput_text.txtand only the last survives. Rename per run.
Where it fits
Saving LLM-generated prompts and captions for later reuse, dumping prompt-batch logs for comparison, or feeding a caption file into a training pipeline. It's the string counterpart to the pack's save-image nodes, and it's the sort of "why is this not built in" utility that keeps getting rebuilt - this one comes free with the pack.
Installing it
Part of ComfyUI_EmAySee_CustomNodes. ComfyUI Manager → search the pack title → Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI
Under EmAySee/Utils, no dependencies.
Bottom line
Text in, .txt out, with subfolders and absolute paths handled. Give it unique filenames and it'll never fight you - forget to, and it'll overwrite you into confusion.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text_to_save | STRING | — | |
| filename | STRING | output_text | — |
| subfolder | STRING | — |
Outputs (0)
No outputs