Save String to File
Stop copy-pasting your prompts into a text file
- contents
Sooner or later you want the workflow to write something down. A prompt log, a settings dump, a caption file for a dataset, the contents of a generated text node. ComfyUI has no built-in "write text to disk" node, and Save String to File is the gap-filler: it takes any string and writes it to a path you specify, with three behaviors for when the file already exists.
It's the output-node sibling of the pack's Load String from File - the two bookend any workflow that persists text. Write captions or config with this, read them back later with that. For batch captioning alone it's worth having: generate a prompt per image, save it as <image_name>.txt next to the image, and you've built a dataset one run at a time.
How it works
Give it a string and an absolute filepath. On execution it checks whether the target exists, then acts according to exists_behavior:
- Overwrite (default) - replace the file's contents.
- Append - add the string to the end of the existing file.
- Ignore - if the file exists, leave it completely untouched.
Parent directories are created automatically, so C:/outputs/logs/run.txt works even when logs doesn't exist yet. It writes UTF-8, and after writing it reads the file back so its output reflects what's actually on disk.
Inputs: string (the text to save), filepath (where to write), exists_behavior (the dropdown). There are no data outputs to wire - it's an output node; the file is the result.
Installing it
Save String to File is part of ComfyUI-TinyBee, a small MIT-licensed utility pack with no models to download. The easy path:
- ComfyUI Manager → Custom Nodes Manager.
- Search "ComfyUI-TinyBee" and install.
- Restart ComfyUI.
Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
Restart and it lives under 🐝TinyBee/Util. Pure standard library under the hood - the pack's jsonata dependency only matters for its JSON Parser node.
Gotchas
The filepath is absolute, full stop. ./notes.txt resolves against ComfyUI's working directory, not your workflow, so type the whole path or compute it from a base folder. Because the node always re-runs when queued, an Overwrite workflow will happily clobber the file every run - switch to Append for a log, or Ignore if you're generating a caption only when it doesn't exist yet. And if the string input comes from a text node you've bypassed, you may get an empty file; check the wire before you blame the disk.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| filepath | STRING | — | |
| exists_behavior | COMBO | Overwrite | 3 options: Overwrite, Append, Ignore |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| contents | STRING | — |