Nodes/ComfyUI-Custom-Scripts/Save Text 🐍
ComfyUI Node Runs on cloud

Save Text 🐍

Write a string to disk from inside your workflow

By pythongosssssΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 3,150
Save Text 🐍
    • STRING
    β—„root_dirβ–Ύβ–Ί
    β—„filefile.txtβ–Ί
    β—„appendβ–Ύβ–Ί
    β—„inserttrueβ–Ί
    β—„textβ€”β–Ί

    Save Text writes whatever string you feed it to a file on disk, without you leaving the graph or writing a Python node yourself. It's the kind of node you don't need until you're batch-generating with dynamic prompts and realize you have no record of which prompt produced which image - at which point it becomes essential.

    It's from ComfyUI-Custom-Scripts, pythongosssss's utility pack. Small, unglamorous, and one of the more genuinely practical nodes in the set once you're doing anything at scale.

    The inputs that matter

    root_dir picks which of ComfyUI's three managed folders the file lands in: input, output, or temp. file is the filename (defaults to file.txt, and can include a relative subpath). text is the multiline string that actually gets written - wire this off a prompt, a caption from an interrogator, a log line, whatever you want on record.

    append controls the write behavior, and the three options genuinely differ in what they're for:

    • append - keeps adding to the same file across runs. This is the one you want for a running log: every prompt a batch produces, appended to one growing file.
    • overwrite - wipes the file clean and writes fresh each run. Useful for a "latest result" file some other process is watching or tailing.
    • new only - writes once and then leaves the file alone on every subsequent run. Good for something you deliberately want to set once and never accidentally clobber.

    insert (on by default) matters specifically in append mode - it's what keeps successive writes from running together into one unreadable blob. Turn it off only if you specifically want raw concatenation with nothing separating entries.

    Output

    A single STRING, and the node's flagged as an output node, so it's a valid endpoint on its own. Wire it into a Show Text node if you want to confirm on the graph what actually got written, rather than opening the file separately.

    Real uses

    Logging every prompt a wildcard or dynamic-prompt batch run produces, so you can trace an image back to the exact string that made it. Pairing with Load Text for a persistent notes or preset file across sessions. Dumping an interrogator or captioning model's output straight to a .txt file for a training dataset - captioning tools generally expect one text file per image, and this is a clean way to generate them inline while you're already running the images through ComfyUI.

    Installing it

    • ComfyUI Manager - search "ComfyUI-Custom-Scripts", install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts, restart.

    No models, no extra Python dependencies.

    Common issues

    Can't find the file you saved. Check root_dir first - input, output, and temp are three genuinely separate folders, and it's an easy mistake to save to one out of habit and go looking in another.

    File keeps growing indefinitely. That's append mode working exactly as designed. If you wanted a fresh file each run, switch to overwrite.

    Nothing gets written on a repeat run. You're on new only and the file already exists from a previous run - that mode is deliberately a no-op once the file's there. Delete or rename the file if you want a clean write.

    Trying to save outside ComfyUI's managed folders. This node scopes to input/output/temp by design, the same as most of ComfyUI's file I/O - you can't (and shouldn't expect to) point it at an arbitrary absolute path elsewhere on disk.

    Categoryutils

    Inputs (5)

    NameTypeDefaultDescription
    root_dirCOMBO3 options: input, output, temp
    fileSTRINGfile.txtβ€”
    appendCOMBO3 options: append, overwrite, new only
    insertBOOLEANtrueβ€”
    textSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”