ComfyUI Extension: ComfyUI-E-Tier-TextSaver

Authored by e-tier-newbie

Created

Updated

0 stars

A node for saving cleaned text outputs, useful for LoRA training. Removes unwanted tokens like <pad> and saves to .txt.

Custom Nodes (0)

    README

    πŸ“¦ ComfyUI-E-Tier-TextSaver

    Sick of annoying <pad> tokens messing up your prompts? πŸ˜‚ This one’s for you.

    A secure and flexible text-saving node for ComfyUI.
    After captioning with Florence2 or similar, it automatically strips unwanted tokens and saves a clean .txt file.


    ✨ Key Features

    • βœ… Removes unwanted tokens like <pad> from caption text
    • πŸ” Strict path validation and filename sanitization
    • 🧩 Works smoothly with Florence/BLIP captioning nodes
    • πŸ“‚ Supports LoRA-style image-text dataset workflows

    πŸ§‘β€πŸ’» Use Case Example

    When training LoRA models, it's common to need .txt caption files that match image filenames.
    This node makes that easy by fitting naturally into a workflow like this:

    [Image Loader] ➑️ [Captioning Node] ➑️ [Text Saver (E-Tier)]
    

    workflow-example


    πŸ” Security Design

    All save paths go through strict validation checks:

    | βœ… Allowed | ❌ Blocked | |-------------------------------|----------------------------------------------------------| | Existing directories only | Non-existent paths (no auto-creation) | | Absolute paths | Relative traversal (e.g., ../) | | Safe characters | Shell/metacharacters (e.g., |, ;, $, etc.) | | Clean text input | Suspicious patterns (e.g., eval, <script>, etc.) |

    πŸ“Œ The final save path is clearly printed to the console for full transparency.


    βš™οΈ Node Parameters

    | Parameter | Description | |-------------|----------------------------------------------------| | text | The text content to be saved (required) | | filename | Filename for the resulting .txt file (required) | | save_to | Output directory selected from a dropdown list |


    About the save_to Parameter

    The save_to dropdown paths are specified in the node's YAML whitelist file. Users can set custom keys (names) and their corresponding directory paths in the YAML whitelist like this:

    whitelist:
      ComfyUI/output: "./ComfyUI/output"
      CustomFolder: "./my_custom_output"
    

    Here, "CustomFolder" is the label shown in the dropdown, and "./my_custom_output" is the actual directory path used for saving files.
    This allows flexible and user-friendly naming of output locations.


    ❗ Other Notes

    • Any validation errors will be clearly displayed in the console or UI.
    • If no filename is given, it defaults to "untitled.txt".
    • This node will not create directories β€” make sure your structure exists.
    • Secure by default, but configurable for advanced users.

    πŸ› οΈ Installation

    git clone https://github.com/e-tier-newbie/ComfyUI-E-Tier-TextSaver
    

    Place the folder under ComfyUI/custom_nodes/ and restart ComfyUI.


    πŸ™ Credits

    E-tier-newbie
    NDY