Write To Text File
The node that stops your prompts from evaporating
- status
ComfyUI is great at keeping a graph of everything that happens between your prompt and your PNG - and terrible at remembering anything else. Text that isn't wired into a conditioning node just sits in a widget and vanishes with the canvas. Write To Text File is the escape hatch: it takes whatever string you feed it and commits it to disk so it survives the run, the restart, and the eventual "which prompt actually made this image" question.
It's part of JasonHoku's Lite Text to File Tools pack, a small collection of text/JSON I/O nodes from the same author as the popular Ultimate Auto Sampler Config Grid Testing Suite. No API calls, no models, no GPU involvement - it's pure Python stdlib writing files.
How it works
You give it three things: the text_input you want saved, a file_prefix, and a mode. The interesting one is mode, which has three values:
- overwrite - the default. Replaces the file entirely.
- append - adds your text on a new line at the end.
- prepend - writes your new text, a newline, then the old contents on top.
The file_prefix isn't a path you get to pick anywhere - everything this pack writes lands inside ComfyUI's output folder. Set it to text/output.txt and the node writes to ComfyUI/output/text/output.txt, creating subdirectories as needed. There's also a path-traversal guard in the code, so a file_prefix like ../../etc/passwd gets rejected rather than silently writing somewhere it shouldn't. Files save as UTF-8.
The only output is a status string - something like ✓ Wrote to .... It's mostly there so you can see the result in the graph, and you can wire it into a Show Text node if you like keeping an eye on things.
Installing it
Grab it through ComfyUI Manager (search "Lite Text to File Tools"), or clone it by hand:
cd ComfyUI/custom_nodes/
git clone https://github.com/JasonHoku/comfyui-lite-text-to-file-tools
# then restart ComfyUI
That's it. No requirements.txt worth worrying about - this pack depends only on Python's standard library plus folder_paths, which ships with ComfyUI core. No model files to download, no CUDA wheels, nothing to break your environment.
Common gotchas
- Append adds a trailing newline, overwrite doesn't. If you're building a file line-by-line with append, every line ends with
\n- fine for logs, annoying if you append then load the file back and find stray blank handling. - Errors come back as strings, not crashes. If something goes wrong, the status output is
✗ Error: ...rather than the node failing. That's handy in a batch run, but it means a typo in yourfile_prefixwon't stop the workflow - it'll just quietly write an error where a status should be. - Where's my file? It's under
ComfyUI/output/, not wherever you were looking. This trips everyone once.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text_input | STRING | — | |
| file_prefix | STRING | text/output.txt | — |
| mode | COMBO | overwrite | 3 options: overwrite, append, prepend |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status | STRING | — |