Create Text File
Write a Text File From Inside Your Workflow
- result_message
- success
Somewhere in every ComfyUI user's life there's a "save this text so I can use it later" moment. The prompts, the metadata, the config JSON, the list of what this run produced - ComfyUI is great at saving images and not great at saving anything else. Create Text File (class name FileCollisionTestNode, don't worry about the name) writes a text file to any path you give it, straight from a workflow.
The display name it's sold under is honest about the simple job: you type a file_path and some file_content, hit queue, and a file exists. It's an output node, so it runs on every execution - which is exactly what you want for logging, for writing prompt batches to disk, or for stashing a manifest alongside your renders.
How it works
Two required inputs, both strings:
file_path- where to write. Relative paths resolve against your ComfyUI working directory; absolute paths work as you'd expect. If the path has no extension, the node appends.txtautomatically. It also creates any missing parent directories, so you can point it atoutput/logs/run_001and the folder structure appears.file_content- the text to write (multiline, so paste your whole prompt or config).
On success it returns result_message (a string like "Test file created successfully at '…'") and a success boolean. Since it's an output node, you don't usually wire those anywhere - the file on disk is the real output, and the message is there for you to eyeball in the console or route to a text preview if you want confirmation.
The original purpose (the class name gives it away) was testing file-collision handling in the pack's Smart File Transfer node - it was a debugging doodad that turned out useful on its own. The genuinely useful patterns: writing per-run prompts to output/<something>/prompt.txt, dumping a workflow's inputs to a config file, or generating a prompts.txt that the pack's Text File Line Loader then iterates over. It's the "echo >> file" of ComfyUI, and sometimes that's all you need.
Install
Search "Trent Nodes" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt
No models, no special dependencies - plain Python file I/O. Restart ComfyUI after installing. (The author has flagged Manager install flakiness on this pack from an early repo rename; the manual clone is the reliable fallback.)
Common issues
- File ended up somewhere unexpected. Relative paths are relative to ComfyUI's working directory, not your output folder. Use an absolute path when it matters.
- Content got mangled. The file is written as UTF-8, so non-ASCII prompts are fine - but if your downstream tool expects a specific encoding or line endings, that's on you to handle.
- "Where's my .json?" If you want a non-
.txtextension, include it in the path - the auto-append only fires when there's no extension at all. - The
successoutput feels useless. It's a boolean for branching if you ever make this node non-output by converting it, but for now the file-on-disk is the deliverable.
For "just write this text to disk," it's a two-field node that does exactly what it says. There's no wizardry here - and that's the point.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| file_content | STRING | This is a test file | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result_message | STRING | — |
| success | BOOLEAN | — |