Write Text With Sequential Numbering
Never overwrite a log file again
This is the one node in the text-file-util pack you'll actually reach for over its siblings once you've been burned by the plain Write Text node once. Same idea - take a string, write it to a .txt file - but with one crucial difference: every run gets a fresh, numbered filename, so nothing ever gets overwritten. No mode = w clobbering your last run's log, no appending garbage into the same file. You queue a batch of 30, you end up with 30 numbered files. That's the whole selling point, and for a tiny single-commit pack that's a genuinely good idea.
How it works
Where Write Text builds the filename from a prefix and a mode, this node borrows ComfyUI's own image-saving machinery: folder_paths.get_save_image_path(). That's the same counter logic ComfyUI uses so your PNGs never collide - it looks at what's already in the output folder and picks the next free number. So with the default filename_prefix of ComfyUI, your first write lands as ComfyUI_00001_.txt, then ComfyUI_00002_.txt, and so on.
Two details worth knowing. First, the extension is its own input, ext, defaulting to .txt - and it's inserted after the counter with an underscore, which is why you get that slightly odd ComfyUI_00001_.txt instead of ComfyUI_00001.txt. It's cosmetic, but it means you can set ext to .json or .md and get ComfyUI_00001_.json if you're logging structured data. Second, the counter is derived from existing files, so it's monotonic across restarts - the next run continues from where you left off instead of resetting to 1.
The inputs that matter
- text - the content. A prompt, settings dump, seed, anything you want a permanent record of.
- filename_prefix - the base name; the counter and extension get appended.
- ext - file extension including the dot, default
.txt.
encoding and newline are the same optional pair as the rest of the pack - utf-8 by default, and LF/CRLF/LFCR for line endings when you care.
Installing it
ComfyUI Manager → search ComfyUI-text-file-util, or:
cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-text-file-util
Restart ComfyUI. No dependencies, no pip install, no models to fetch - the whole pack is plain Python with no requirements file.
Where people get burned
The main confusion is location, same as every node here: files land in ComfyUI/text_output/, not your usual output/ folder. It's easy to miss the file entirely if you're expecting it next to your images. The other thing to know is that this node can only write - it's an output node with no data wires coming out - so it's a dead-end terminal for logging, not something you chain into further nodes. And while it fixes the overwrite problem, it has no append mode, so if you genuinely want one accumulating file, the plain Write Text node with mode = a is the better pick. For one-unique-file-per-run, though, this is the right tool and it does the job without you ever thinking about filename collisions again.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| ext | STRING | .txt | — |
| filename_prefix | STRING | ComfyUI | — |
| encodingopt | STRING | utf-8 | — |
| newlineopt | COMBO | 3 options: LF, CRLF, LFCR |
Outputs (0)
No outputs