Nodes/ComfyUI_StringOps/文本写入TXT🐠meeeyo.com
ComfyUI Node

文本写入TXT🐠meeeyo.com

Log Prompts and Metadata to a TXT File in 30 Seconds

By MeeeyoAI·Created 2 years ago·Updated about a year ago· 209
文本写入TXT🐠meeeyo.com
  • any
  • STRING
text_content
file_pathpath/to/your/file.txt

Text in ComfyUI lives inside the graph. That's great while you're working and useless the moment you want a record of what you actually generated. When you need an audit trail for a client batch, a log of prompts and seeds across a long run, or a text file to feed a downstream tool, you have to get that string out of ComfyUI and onto disk. That's the entire job of WriteToTxtFile: take any text, write it to a .txt file, and hand the text right back so your workflow doesn't stop.

It comes from ComfyUI_StringOps, a small Chinese-language utility pack by a creator who goes by Meeeyo (觅鱼 AI, meeeyo.com). Every node in the pack has a "🐠meeeyo.com" branded display name and the descriptions pitch a paid WeChat community - it's an indie pack with basically zero presence in English-speaking circles, but the file nodes are clean, simple Python, which is exactly what you want from a node that writes to your disk. Install it once and the whole pack comes along.

How it works

Under the hood it's plain file I/O, and there's one behavior you must internalize before your first run: it appends to existing files instead of overwriting them. The logic is:

mode = 'a' if file_exists else 'w'

If the file already exists, it opens in append mode and sticks two blank lines before your new text. If it doesn't exist, it creates it. On top of that, IS_CHANGED returns NaN, which means the node re-runs on every queue pass - so if you leave everything in place and hit generate again, you get your text duplicated in the file. Every. Single. Time.

The inputs and output

  • text_content - a multiline string. Paste anything in, or wire it from other nodes: your positive/negative prompt, a seed, a timestamp, a filename list from a batch loop. Whatever string you feed it is what lands in the file.
  • file_path - where to write. It creates parent directories automatically, so a path like D:/logs/run/prompts.txt works even if run/ doesn't exist yet.

The STRING output echoes what happened: "Write successful: <your text>" or "Error: <message>". Because it returns your text back, you can tee it - send the same string to the prompt and to the file in one go, or chain the result into a text display to confirm the write.

The trap, and how to dodge it

Append-not-overwrite is the one that bites everyone. Re-running a workflow duplicates the content, and a hundred duplicated prompt blocks in a log file is annoying to clean up. Two ways out:

  • Delete the file when you want a fresh start.
  • Give each run its own path - the same pack's GetCurrentTime node can stamp a timestamp into file_path, so D:/logs/run/prompts.txt becomes D:/logs/run/prompts-20260816.txt.

Also note that relative paths resolve against the directory you launched ComfyUI from, not ComfyUI's root - use absolute paths unless you like guessing. It writes UTF-8 only, which is fine for almost everything and a non-issue for prompt logs.

Install

ComfyUI Manager: search "StringOps", install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps
# restart ComfyUI

The pack's requirements.txt lists torch and friends, but this node only needs the Python standard library - ComfyUI's existing environment is plenty. No models, no downloads.

It's the kind of node you forget exists until a client asks "can you show me what prompts you used?" and you realize you can hand them a plain text file instead of screenshots of your graph. Just remember the append behavior, and it'll treat you well.

CategoryMeeeyo/File

Inputs (3)

NameTypeDefaultDescription
text_contentSTRING
file_pathSTRINGpath/to/your/file.txt
anyopt*

Outputs (1)

NameTypeDescription
STRINGSTRING