Nodes/Comfyui_JTnodes/JT Save Text to File
ComfyUI Node

JT Save Text to File

Turn ComfyUI's throwaway text outputs into real files

By Jint8888·Created about a year ago·Updated about a year ago· 1
JT Save Text to File
    • STRING
    text
    folder_path/path
    filenameoutput.txt
    write_modeappend

    Text in ComfyUI is ephemeral by default: you generate a prompt or an LLM response, look at it in a preview box, and the next run wipes it. JT Save Text to File fixes that by writing a string to a real file, in append or overwrite mode, wherever you want it on disk. It's the logging node of the pack, and once you've used it you'll wonder why this isn't built in.

    Why you'd reach for it

    Three use cases cover most of it. First, logging: capture every prompt you actually ran, in order, in a plain text file - invaluable when you're iterating on a look and want to see which wording produced which batch. Second, persisting LLM output: wire the text out of the JT Siliconflow LLM node into this, and every model response gets saved to disk instead of vanishing. Third, feeding downstream tools: write a prompt, a list, or a config string to a file that a script or another app reads.

    The inputs

    • text (STRING, multiline) - what to write. Comes from any text-producing node.
    • folder_path (STRING) - destination folder, created automatically. Default /path - change it.
    • filename (STRING) - default output.txt. Unlike the Excel nodes, no extension is auto-added here; type it yourself.
    • write_mode (append / overwrite) - default append.

    The single output returns the text you just saved, so you can chain the write into the rest of your workflow.

    How it works, and the append gotcha

    Open the file, write, done. Folder auto-created, UTF-8 encoding, and in append mode it inserts a newline before your text if the file already has content - so sequential writes stack up as one line each instead of gluing together. That's a thoughtful detail.

    The behavior to keep an eye on: default mode is append. If you rerun a workflow ten times, the file grows ten entries. That's usually what you want for a log, but if you're regenerating a config file or a prompt you intend to paste elsewhere, switch to overwrite or you'll be deleting old runs by hand. There's no counter or dedup - this node assumes you know whether you're accumulating or replacing.

    Gotchas

    • The /path default. Yes, again - every node in this pack ships with it, and it will write into a directory at your filesystem root if you forget.
    • No extension auto-append: filename is used verbatim, so prompt_log produces a file with no extension.
    • Appending to a file that's open in another editor can hit file locks on Windows.

    Installing it

    Ships in Comfyui_JTnodes with the rest of the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Jint8888/Comfyui_JTnodes
    pip install "openai>=1.0.0" "openpyxl>=3.0.0"
    

    or search "Comfyui_JTnodes" in ComfyUI Manager. This particular node needs nothing beyond Python's stdlib - but the pack as a whole imports openai at load time and has no requirements.txt, so run that pip install anyway or the entire pack fails to import and you won't see any JT nodes, including this one. Restart ComfyUI; it's under JT > JT/text.

    The README is in Chinese, but this is about the simplest node in the pack - a couple of dozen lines, no surprises. If you keep running generations and losing track of what prompts produced what, this is the node that ends the mystery.

    CategoryJT/text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    folder_pathSTRING/path
    filenameSTRINGoutput.txt
    write_modeCOMBOappend2 options: append, overwrite

    Outputs (1)

    NameTypeDescription
    STRINGSTRING