Nodes/AntiMatter Nodes/Antimatter Text File Appender
ComfyUI Node

Antimatter Text File Appender

Save every prompt — and overwrite the one that changed

By AntiMatterComfy·Created 3 months ago·Updated 27 days ago· 0
Antimatter Text File Appender
    • saved_text
    • file_path
    text
    directory/tmp/ComfyUI/output
    filenamesaved_text
    file_formattxt
    prefix
    blank_lines_between_entries1
    index_start1
    index_padding0
    json_indent2
    text_input
    scene_name

    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_indent controls pretty-printing; set it to 0 for compact JSON.
    • TXT mode appends text blocks separated by blank_lines_between_entries blank 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.

    CategoryAntiMatter/Text

    Inputs (11)

    NameTypeDefaultDescription
    textSTRING
    directorySTRING/tmp/ComfyUI/output
    filenameSTRINGsaved_text
    file_formatCOMBOtxt2 options: txt, json
    prefixSTRING
    blank_lines_between_entriesINT10–20
    index_startINT10–1000000000
    index_paddingINT00–12
    json_indentINT20–8
    text_inputoptSTRING
    scene_nameoptSTRING

    Outputs (2)

    NameTypeDescription
    saved_textSTRING
    file_pathSTRING