Nodes/ControlFlowUtils/๐Ÿ’พ Save Text File
ComfyUI Node

๐Ÿ’พ Save Text File

Stop Losing Your Prompts and Logs to the Void

By VykosXยทCreated 2 years agoยทUpdated 2 years agoยท 147
๐Ÿ’พ Save Text File
    • SUCCESS?
    โ—„file_pathout.txtโ–บ
    โ—„modeโ–พโ–บ
    โ—„terminatortrueโ–บ
    โ—„textโ€”โ–บ

    Plain text has a way of evaporating in ComfyUI. You generate with a prompt, save the image, and the exact wording lives only inside the PNG metadata - assuming the workflow even saves it. SaveTextFile (๐Ÿ’พ Save Text File, from ControlFlowUtils) gives you a dead-simple way to write text out to a real file, wherever you want it.

    This is one of those "small node, huge quality-of-life" additions. It's the write half of the pack's file pair - ReadTextFile is the read half - and together they cover logging, wildcard lists, trigger-word collections, and batch metadata.

    How it works

    You give it a file path and some text; it writes the text as UTF-8. That's the whole job, plus three decisions:

    • file_path - absolute or relative path (default out.txt). Relative paths resolve against wherever ComfyUI runs from, so get in the habit of using absolute paths unless you enjoy hunting for stray files.
    • mode - how to write:
      • append - add new lines to the end, existing content untouched. The natural mode for logs.
      • overwrite - delete and replace. Good for regenerating a wildcard file.
      • new only - fail if the file already exists. The "don't clobber my work" safety mode.
    • terminator - on by default; appends a newline after each append so the next write starts on a fresh line instead of gluing onto the end.
    • text - the content, a multiline box. Right-click it and Convert to input to drive it from another node - that's how you log dynamic data like a current prompt or seed.

    The output is a single SUCCESS? boolean - True if the write worked, False if not. Wire that into an IfConditionSelector if you want the workflow to react when a write fails.

    Where people actually use it

    The two killer use cases: logging and wildcard generation. In a batch loop, append the prompt and seed each iteration and you end up with a plaintext record you can grep - no digging through image metadata. For wildcards, have a workflow generate a set of variations and overwrite a triggers.txt that another workflow reads. The author explicitly calls out "lora triggers" and "logs of your workflow execution" as the intended jobs, and both are exactly as smooth as this node makes them.

    Where you'll get burned: the new only mode. It sounds like "don't overwrite," and it is, but it also means the second run of your workflow fails the write because the file from the first run exists. And because there's no confirmation prompt - only the SUCCESS? output - a misspelled path writes a file somewhere you won't think to look. Check the path first, and wire SUCCESS? into something if a failed write is a problem for you.

    Install

    SaveTextFile is part of VykosX/ControlFlowUtils:

    # ComfyUI Manager โ†’ Install Custom Nodes โ†’ search "ControlFlowUtils"
    # or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/VykosX/ControlFlowUtils
    

    Restart, and it lives under ๐Ÿบ VykosX-ControlFlowUtils. Zero dependencies, zero model files - the whole pack installs clean. It's been at v0.0.6 Alpha since late 2024, but for a node this simple "stable, unmaintained" is indistinguishable from "done."

    Category๐Ÿบ VykosX-ControlFlowUtils

    Inputs (4)

    NameTypeDefaultDescription
    file_pathSTRINGout.txtAbsolute or relative path of the file to write to
    modeCOMBOMode that the file should be written as
    terminatorBOOLEANtrueWhether to include a new line after appending to the file
    textSTRINGText to write to the file. Right Click and convert to input to specify dynamicaly

    Outputs (1)

    NameTypeDescription
    SUCCESS?BOOLEANReturns True if the file was successfully written to, False otherwise