Nodes/ComfyUI-Addoor/🌻 Text Saver
ComfyUI Node

🌻 Text Saver

Write a string to a file with auto-numbered naming

By Eagle-CN·Created 2 years ago·Updated about a year ago· 75
🌻 Text Saver
    • File_Path
    text
    directory./ComfyUI/output
    filename_prefixComfyUI
    filename_delimiter_
    filename_number_padding4
    file_extension.txt
    encodingutf-8

    Writes a string to a text file. That's the job - but it's the piece that lets a ComfyUI graph save text the way it saves images, which turns out to matter a lot once you're captioning, logging, or building datasets. Give it a string and a folder and it drops a numbered .txt next to your other outputs.

    Where it fits

    ComfyUI is built to output images; saving text is an afterthought it doesn't do natively. But plenty of workflows produce text worth keeping - a caption from a vision model, a generated description, a log line, an assembled prompt. The obvious pairing is captioning for training: run an image captioner, then Text Saver writes each caption to a .txt, and if you match its naming to your Image Saver you get image/caption pairs (img_0001.png + img_0001.txt), which is exactly the layout LoRA trainers expect.

    How it works

    It writes the incoming text to the directory you name, building the filename from filename_prefix, filename_delimiter, and filename_number_padding with automatic numbering. The optional file_extension lets you write something other than .txt (say .json), and encoding defaults to utf-8. Per the pack's README, the directory and prefix also support time-based tokens, so you can bucket outputs by date if you set them up that way.

    The inputs that matter

    • text - the string to write. Wire it from whatever produced the text.
    • directory - where the file goes. Defaults to ./ComfyUI/output.
    • filename_prefix / filename_delimiter / filename_number_padding - the naming scheme (e.g. ComfyUI_0001). Match these to your Image Saver for paired files.
    • file_extension (optional) - .txt by default; change it for other formats.
    • encoding (optional) - utf-8 unless you have a reason otherwise.

    The output is File_Path, the full path it wrote - handy to pass into a zip or cleanup node downstream.

    Common issues

    If you're building image/caption pairs, the naming scheme has to match your image saver exactly - same prefix, delimiter, and padding - or the .txt and .png won't line up by name and your dataset loader won't pair them. Keep encoding on utf-8 unless you're dealing with a tool that demands something else; mismatched encoding is how you get mojibake in captions, especially with non-Latin text. And directory is a path on the ComfyUI host, so on a cloud instance the file lands server-side - grab it via File_Path (e.g. into a Zip Save) rather than expecting it on your own machine.

    Installing ComfyUI-Addoor

    ComfyUI-Addoor (葵花宝典) is a utility pack from developer Eagle-CN. ComfyUI Manager: Install Custom Nodes → search "ComfyUI-Addoor" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Eagle-CN/ComfyUI-Addoor.git
    cd ComfyUI-Addoor
    pip install -r requirements.txt
    

    Restart and find it under 🌻 Addoor / Utilities. Pair it with an image captioner and Image Saver to build training datasets.

    Category🌻 Addoor/Utilities

    Inputs (7)

    NameTypeDefaultDescription
    textSTRING
    directorySTRING./ComfyUI/output
    filename_prefixSTRINGComfyUI
    filename_delimiterSTRING_
    filename_number_paddingINT40–9
    file_extensionoptSTRING.txt
    encodingoptSTRINGutf-8

    Outputs (1)

    NameTypeDescription
    File_PathSTRING