Antimatter Text File Appender
Save every prompt — and overwrite the one that changed
- saved_text
- file_path
If you've ever rebuilt a great workflow and realized you can't remember the exact prompt that produced a keeper, you know why a "write this text to disk" node earns its place. Antimatter Text File Appender saves whatever string you feed it to a .txt or .json file - and it can either append like a log, or replace a specific scene when you're doing manual rework on a scene-based project. It's the kind of plumbing node that makes ComfyUI feel like a real pipeline instead of a screenshot machine.
How it works
You give it text (from the widget, or from a connected text_input - if something's plugged in, that wins) and it writes to directory + filename. No extension? It adds .txt or .json for you. Writes are protected by a file lock, so parallel runs won't mangle each other, and the node forces re-execution on every queue run so your log actually captures each run.
The prefix field is the fun part. It supports placeholders: {index} / {counter} for an auto-incrementing number (with index_start and index_padding for zero-padding), plus {date}, {time}, and {datetime}. So a prefix like scene_{index:03d} - well, {index} with index_padding set to 3 - gives you cleanly numbered entries.
JSON vs txt
- JSON mode writes records as a list of objects:
timestamp,index,prefix,text,saved_text.json_indentcontrols pretty-printing; set it to0for compact JSON. - TXT mode appends text blocks separated by
blank_lines_between_entriesblank lines.
Scene replacement (the headline feature)
Wire the Scene Name output from LinePrompt_MasterLoad_JSON into scene_name and the appender stops logging and starts editing. Give it 35, scene-035, or scene_35 and:
- For JSON, it replaces the record that matches that scene name or index.
- For txt, it replaces the block that contains a matching scene marker (
scene-035,scene 35, even Russianсцена); if no marker matches, it replaces the N-th text block.
This is the workflow that makes sense of it: you're regenerating scene 35 for the fourth time, and instead of stacking four stale prompt copies in your project file, the appender overwrites scene 35's entry. Your prompt file stays in sync with what's actually on disk. Read it as "save me a record of every generation" and you'll be disappointed; read it as "keep my scene manifest accurate" and it clicks.
Outputs
saved_text- the full text that was written, prefix included. Loop it back anywhere.file_path- the absolute path, handy for wiring into a file-reading node or just confirming where it landed.
The default directory is ComfyUI's output folder, so check where it's writing before you go hunting.
Installing it
It's part of AntiMatter Nodes. Clone once and it's yours:
cd ComfyUI/custom_nodes
git clone https://github.com/AntiMatterComfy/antimatter-nodes.git
Restart ComfyUI after cloning. There are zero extra Python dependencies and no model downloads - this node is pure stdlib, which is why it never fights your environment.
Troubleshooting
The one that bites: an existing JSON file must be a JSON array, or the node raises instead of quietly corrupting your file (the writes are atomic - it writes a temp file and swaps it in, so a crash mid-write won't trash the log). And if scene replacement ever replaces the wrong block, it's because your txt entries don't carry a recognizable scene marker - put scene-035 in the saved text and the matching is exact.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| directory | STRING | /tmp/ComfyUI/output | — |
| filename | STRING | saved_text | — |
| file_format | COMBO | txt | 2 options: txt, json |
| prefix | STRING | — | |
| blank_lines_between_entries | INT | 10–20 | — |
| index_start | INT | 10–1000000000 | — |
| index_padding | INT | 00–12 | — |
| json_indent | INT | 20–8 | — |
| text_inputopt | STRING | — | |
| scene_nameopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| saved_text | STRING | — |
| file_path | STRING | — |