Write Text Lines (For List)
The batch writer, and its one big trap
If you've got a list of strings - generated prompts, tags, filenames, a batch of anything - and you want them all dumped into one text file, this is the node. It's the batch sibling of the pack's plain Write Text node: same install, same text_output/ folder, same w/a mode logic, but instead of one string it accepts a whole list and writes every item in order. The classic job for it is LoRA dataset prep, where you want a prompt file per image or a single file holding a batch of prompts you'll read back later.
One caveat before you rely on it: this pack is a single-commit hobby project from 2024, and this node is where the rough edges show. Read the trap below or you'll think it's broken.
How it works
The texts input is the difference. It's marked as a list input, so you wire it to a node that outputs a list of strings - a prompt generator, a batch text node, an array from a workflow - rather than a plain text field. On each queue run it opens the file and writes every item in the list, in order.
Here's the trap: it writes the items with no separator between them. The loop is literally write(item) for each one. There's no implicit \n, no line joining. The node is called "Write Text Lines," but it will happily glue ten prompts into one run-on blob if the items you feed it don't already end in newlines. So the practical rule is: make sure each string in your list carries its own line ending, or do the newline-joining upstream before the node. newline (LF / CRLF / LFCR) controls the line endings that are present - pick CRLF if the file's going to a Windows tool.
The inputs that matter
- texts - the list of strings to write. The whole point of the node.
- mode -
woverwrites,aappends. For a batch you usually wantwon the first pass, or you'll accumulate duplicates every run. - file_name + filename_prefix - same
<prefix>_<name>.txtscheme as the rest of the pack, so defaults give youComfyUI_text.txt.
encoding defaults to utf-8; leave it alone unless you know you need something else.
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 pip step, no requirements - this pack is pure Python stdlib, which is why the install is painless.
Where people get burned
Two things, and both are visible in the source. First, the missing-separator behavior above - check your output file after the first run and you'll see immediately whether your list items carried their own newlines. Second, a real quirk: if you put a subfolder in filename_prefix (like logs/prompts), this node creates that folder but then ignores it for the actual write, dumping the file in the top-level text_output/ anyway. It's a leftover from copying the Write Text logic. So don't rely on subfolders here - just use a flat filename_prefix and keep the folder tidy yourself.
And the usual one: the file lands in ComfyUI/text_output/, not output/. If you're new to the pack, that's the first place to check.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| texts | STRING | — | |
| file_name | STRING | text.txt | — |
| filename_prefix | STRING | ComfyUI | — |
| mode | COMBO | 2 options: w, a | |
| encodingopt | STRING | utf-8 | — |
| newlineopt | COMBO | 3 options: LF, CRLF, LFCR |
Outputs (0)
No outputs