CB Save Text File ⚡️
Overwrite, append, or start a numbered log
- saved_text
What it's for
Writing a string to a .txt file inside ComfyUI's output folder. That sounds almost too small to need a node, right up until you want any of these: a running log of prompts and seeds as you iterate, a caption sidecar next to a batch of images, or a value handed from one queued run to the next.
That last one is the sneaky-important case. When you chain runs - queue stage one, let it finish, queue stage two - nothing carries over except what you wrote down. People doing staged execution to keep VRAM free end up using save-text/load-text exactly this way, because it's the only channel that survives a new queue.
text_input is a string and saved_text hands it back out, so you can log a value and keep using it in the same graph. It's an output node, which means it writes on every queue, unconditionally.
The three modes are the whole node
overwritereplaces the file contents. The default, and the right choice for a "current settings" file.appendadds to the end. If the file exists and isn't empty, it prefixes a newline first, so you get one entry per line rather than a word-soup. Use it for a log.incrementnever touches an existing file. Ifconfig1.txtexists, it writesconfig1_00001.txt, or the next free number after that - a five-digit counter, so it sorts sanely in a file browser.
file_path is relative to your ComfyUI output directory, and it's enforced the same strict way as the reader: no absolute paths, no drive letters, no .. segments, and containment is verified against the resolved base so a symlink can't get you out. Missing parent folders are created for you. It's a defensive design and the reason it's locked to output/ rather than root - you can't accidentally point a node at your keys.
One quirk worth knowing: errors don't raise, they come back as the output string. A rejected absolute path returns Error: Absolute paths are not allowed: '...' on saved_text, and if you wired that output onward, you're now feeding an error message into the rest of your graph. Check the string if things look odd.
Inputs and outputs
| | |
|---|---|
| file_path (STRING, default configs/config1.txt) | relative to the ComfyUI output folder |
| mode (enum: overwrite, append, increment) | as above |
| text_input (STRING) | the text to write - connection only, no typing into this one |
| saved_text (STRING, output) | what was written, so you can carry on using it |
Installing it
Manager → Custom Nodes Manager → search ComfyUI CoolB Nodes → Install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/CoolBreeze164/ComfyUI-CoolB-Nodes
No models, no dependencies. Nothing to configure - the folder gets created on first write.
Common issues
You can't type into text_input. That's deliberate: the input is declared as a forced connection, so it only accepts a wire. Feed it from a text box, a prompt node, or a CB Textbox if you want to see the value on canvas too.
A file appeared that you didn't want. Output nodes always run. If you queue ten times you get ten log entries, or ten numbered files in increment mode. That's the point for a log and a surprise if you were using it as a one-off.
append glued two entries together. It only inserts the leading newline when the file already has content, so the very first append writes bare text. If your own string doesn't end in a newline, the second entry will start on a new line and the first won't have one above it.
You pointed it at an absolute path. Rejected, with the reason handed back on the output. Same for .. and drive letters. Everything is output-relative by design.
Your writes are burying your gallery. Everything lands in output/, which is where your generated images go. Use a subfolder from the start - logs/, captions/, state/ - and pair it with the reader using a matching path.
The increment numbering surprised you. It starts at 00001 for the second file, because the bare name is the first one. If you expected config1_00000.txt, that's not what it does.
Sidecar idea worth stealing. In a training set, the caption for 0001.png is 0001.txt - same basename, plain text, trivially greppable. A text writer with increment mode gets you close to that convention for generated batches, and it's a lot more useful than trying to read captions back out of PNG metadata.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | configs/config1.txt | The path where the text file will be saved, relative to the ComfyUI output folder. |
| mode | COMBO | overwrite | overwrite: Replaces the file content. append: Adds text to the end. increment: Creates a new file like config1_00002.txt if 00001 already exists. |
| text_input | STRING | The text string you want to write into the file. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| saved_text | STRING | — |