Save Text (SBTools)
A Save Text node that won't lose your file — sequential numbering, overwrite, or append
Every ComfyUI workflow eventually produces a string you want to keep - a generated prompt, a caption, an API response, a list of filenames. The default answer is the Show Text node, which is great until ComfyUI restarts and the text is gone. Save Text writes it to a file on disk instead, with three write modes and full control over where it lands.
It's the newest node in this pack (added in v1.6.0) and the only one in the SBTools/Text category. It's a terminal node - no outputs, you wire it at the end of a chain - and it's been through some real hardening in recent versions: the changelog shows fixes for sequential numbering restarting, silent overwrites, and even a path-traversal hole in the separator input. That last one is worth noting: this is a pack whose author clearly found people trying to write outside the output directory, and closed it off.
How it works
You connect a STRING (the text input, which is forced as a link input) and set where it goes:
folder_path- subfolder relative to ComfyUI's output directory. Supportsstrftime, so%Y/%m/%dgives you date-nested folders.filename_prefix- base filename, alsostrftime-aware. Defaulttext_output.extension- no dot needed, it's added automatically. Defaulttxt.
Then the mode:
- Sequential - appends a zero-padded counter (
text_output_001.txt) and always creates a new file.counter_digits(1–9, default 3),counter_position(Back or Front), andseparatorcontrol the numbering shape. This is the one for batch runs where you never want to clobber anything. - Overwrite - replaces the file with the same name. Default.
- Append - adds text to the end of an existing file (inserts a newline only when the file already has content). Use it to build up a log across many runs.
The things that'll save you
Two safety features are worth knowing before you hit a wall. First, path traversal (../) is blocked - everything stays inside the ComfyUI output directory, no escaping. Second, strftime runs at save time, so %Y%m%d_%H%M%S in your prefix gives every batch run a timestamped name automatically; combine that with Sequential and you get a clean, collision-free file history.
Also note the mode interplay: counter_digits, counter_position, and separator only do anything in Sequential mode, and in recent versions the sequential counter is scoped to the whole folder (plus extension and counter position), so two different prefixes in the same folder share one rising sequence instead of both starting at 0001. Files are always written UTF-8.
Installing it
Same pack, same drill. ComfyUI Manager → search "ComfyUI-SBTools" → Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Amatsukast/ComfyUI-SBTools.git
cd ComfyUI-SBTools
pip install -r requirements.txt
Dependencies are trivial (huggingface_hub and kornia, neither of which this node uses - it's pure standard library). Restart ComfyUI after.
Troubleshooting
- File not appearing where expected - remember it's relative to ComfyUI's output folder, and
strftimefolders are created at save time. Check the console for the actual path. - "FileExistsError" or missing sequence number - you're on an older version with the pre-2.0.1 numbering bugs;
git pullthe pack. The current code guarantees Sequential never overwrites. - Odd characters in filenames - the separator input is sanitized now, but keep it simple anyway; a
_or space is all you need. - Writing to a specific absolute path - you can't (by design). The node is sandboxed to the output directory.
It's a boring node, which is the nicest thing you can say about a node that touches your filesystem. Wire it up once, set Sequential, and never think about it again.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Text content to save to file | |
| folder_path | STRING | Subfolder path relative to ComfyUI output directory. Supports strftime format (e.g., %Y/%m/%d) | |
| filename_prefix | STRING | text_output | Base filename. Supports strftime format (e.g., %Y%m%d_%H%M%S) |
| extension | STRING | txt | File extension (dot is added automatically) |
| save_mode | COMBO | Overwrite | Sequential: numbered files. Overwrite: replace existing. Append: add to existing |
| counter_digits | INT | 31–9 | Number of digits for zero-padded counter (only used in Sequential mode) |
| counter_position | COMBO | Back | Counter placement relative to filename (only used in Sequential mode) |
| separator | STRING | _ | Character between filename and counter (only used in Sequential mode) |
Outputs (0)
No outputs