Nodes/ComfyUI/Save Text
ComfyUI Node Runs on cloud

Save Text

Write any string to disk from the graph

By Comfy-Org·Created 4 years ago·Updated about 23 hours ago· 129,495
Save Text
    • text
    text
    filename_prefixComfyUI
    formattxt

    ComfyUI saves your images, but the interesting text - the prompt that produced them, the caption you generated, the params you're experimenting with - usually evaporates when you close the tab. SaveText is a dead-simple output node that writes any STRING to a file inside ComfyUI's output, input, or temp directories. That's it. No API, no keys, no model. It's the "journal" node for people who keep forgetting what they generated.

    How it works

    The node is marked OUTPUT_NODE = True and its IS_CHANGED returns NaN, which means ComfyUI always re-runs it even if the inputs look the same - so your file always reflects the current run. You pick a root_dir from a dropdown that's populated live from ComfyUI's actual directories (output, input, temp), give it a file name, and it writes.

    The three write modes matter more than they look:

    • append - adds to the end of the file (with a newline, controlled by the insert toggle). Perfect for a growing log of prompts. The insert switch disables itself unless you're in append mode.
    • overwrite - replaces the file every run. Good for a "latest prompt" file.
    • new only - refuses to touch an existing file and raises an error if one's there. Useful when you never want to clobber prior work.

    Under the hood it's pathlib plus open(mode=...) with UTF-8 encoding, creating parent folders as needed. Inputs are root_dir, file, append, insert, and the text you want saved (multi-line, and it accepts a wired STRING from other nodes).

    Outputs

    Two of them, and they're handy: text (echoes what you wrote, so you can keep the graph flowing to other nodes) and file_path (the absolute path where it landed - wire this to a text display or another file node).

    Installing

    SaveText ships in the DJZ-Nodes pack by Drift Johnson (MushroomFleet). Install the pack once:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/DJZ-Nodes
    cd DJZ-Nodes
    pip install -r requirements.txt
    

    Or search "DJZ-Nodes" in ComfyUI Manager. This node itself pulls nothing extra - it uses ComfyUI's built-in folder_paths module.

    Real uses

    A few ways people actually run this:

    • Log every prompt + seed to one running file during a long generation session, then grep it later.
    • Persist a caption next to a dataset folder as you build training data.
    • Dump a prompt to input/ where another tool expects a .txt file.

    One caveat: the root_dir dropdown is generated at node-creation time from ComfyUI's paths, so if you're on a portable install, make sure it's showing your real output folder. And new only mode is strict - delete the file (or switch modes) if you legitimately want to overwrite. For a "log everything" habit, append with insert on is the setting to leave it on.

    Categorytext

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    filename_prefixSTRINGComfyUI
    formatCOMBOtxt4 options: txt, csv, md, json

    Outputs (1)

    NameTypeDescription
    textSTRING