LoRA Txt Loader
Automatically loads trigger words from a .txt file with the same name as the LoRA. Supports offline use and custom-trained models.
Nodes (5)
Your LoRA's Next Thumbnail Is One Click Away
Your LoRA trigger words, in a plain .txt file next to the model
The same trigger-word loader, but with a normal dropdown
The LoRA loader that reads the .txt itself, for path-driven workflows
A plain .txt file loader, for prompt snippets you reuse everywhere
LoRA Txt Loader — ComfyUI Custom Node
A ComfyUI custom node that loads LoRA trigger words from a local .txt file — fully offline, fully customizable, no metadata dependency.
How It's Different
Most existing LoRA loader nodes get trigger words from one of two sources:
- Model metadata baked into the
.safetensorsfile (often incomplete or missing entirely) - Civitai API — requires internet access, and only works for models publicly hosted on Civitai
LoRA Txt Loader takes a different approach.
You maintain a plain .txt file next to each LoRA, and the node reads from it directly. This means:
- Works completely offline
- Works for self-trained models that have never been uploaded anywhere
- Trigger words are exactly what you wrote — no guessing, no scraping
- You're in full control
Features
- 📁 Cascade folder browser — browse your LoRA folders in a tree-style dropdown menu, no more scrolling through hundreds of files in a flat list
- 🔍 Built-in search — type to filter across all LoRAs instantly
- 🖼️ LoRA preview on hover — hover over any LoRA in the cascade menu to see its preview image (new)
- 📄 Auto-loads trigger words from a
.txtfile with the same name as the LoRA - ✏️ Editable text box — modify trigger words directly in the node before running
- 🔄 Auto-fills on LoRA switch — when you select a different LoRA, the text box updates automatically
- ↩️ Reset button — one click to restore the original
.txtcontent if you've edited it - 📐 Remembers node size — manually resizing the node is preserved when switching LoRAs
- 🔌 Drop-in replacement for the native Load LoRA node — same inputs, same outputs, plus extras
- 💾 LoRA Preview Saver — save generated images as preview thumbnails for connected LoRAs with one click (new)
What's New (Optimized Fork)
LoRA Preview on Hover
When browsing LoRAs in the cascade menu, hover over any LoRA file to see its preview image in a popup beside the menu.
- Looks for preview images next to the LoRA model file, in order of priority:
{lora_name}.png/.jpg/.jpeg/.webp{lora_name}.preview.png/.preview.jpg(Civitai export format)
- 400ms hover delay prevents flickering when moving across items quickly
- Popup auto-hides when no preview image exists — no empty boxes
- Auto-positions to the right (flips to the left when viewport edge is near)
LoRA Preview Saver Node
A new output node (LoRA Preview Saver) that lets you save a generated image as the preview for all connected LoRAs with one click.
How it works:
- Connect the
lora_pathoutput ofLoRA Txt LoaderorLoRA Txt Loader (From Path)to thelora_path_Ninputs (supports up to 8) - Connect the generated image (from VAE Decode) to
images - Run the workflow — image is saved to
output/as usual, and LoRA paths are auto-filled into an editable text area - Remove any bypassed/muted LoRA paths from the text area (only keep the ones actually used for this image)
- Click
💾 Save as LoRA Previews
Smart behavior:
| Scenario | Result | |----------|--------| | LoRA A has preview, B does not | B saved, A skipped | | Neither has a preview | Both saved | | Both already have previews | Both skipped | | Non-model file path | Rejected with error |
Bug Fixes
| Category | Description |
|----------|-------------|
| Path traversal | get_txt_file API now validates input paths stay inside the texts/ directory |
| Path traversal | save_lora_previews API prevents directory escape for image path |
| File type validation | Preview saver rejects non-model file paths (e.g., .txt, .png) to avoid accidental overwrite |
| Async race | Cascade menu closed during network fetch no longer causes TypeError on destroyed DOM |
| XSS (×5) | All innerHTML usage replaced with textContent / DOM API — folder names, file paths, and preview captions are safely rendered |
| Race condition | TxtFileLoader value setter now uses sequence numbers to discard stale responses |
| Stale data | Preview saver clears _lastImageData when workflow execution fails |
| Stale positioning | Preview popup recalculates position at render time to handle viewport scroll during hover delay |
| Optional chaining | Guard against null.popup.classList TypeError when popup not yet created |
Nodes
1. LoRA Txt Loader (recommended)
The main node. Uses a cascade folder browser with built-in search to select a LoRA. Auto-fills the prompt text box from the adjacent .txt file. Includes a Reset button. Hover over any LoRA to see its preview image.
2. LoRA Txt Loader (Dropdown)
Same as above but uses the standard ComfyUI dropdown instead of the cascade browser. Useful if you prefer the classic interface or have compatibility issues with the cascade menu.
3. LoRA Txt Loader (From Path)
Takes a direct file path string as input instead of a dropdown. Useful for dynamic workflows where the LoRA path is generated by another node. Reads trigger words from the adjacent .txt file automatically.
| Input | Description |
|-------|-------------|
| model | Connect from checkpoint loader |
| clip | Connect from checkpoint loader |
| lora_path | Full path to the .safetensors file |
| strength_model | LoRA model strength |
| strength_clip | LoRA CLIP strength |
4. Txt File Loader
Loads a standalone .txt file from the ComfyUI/input/texts/ folder into an editable text box. Useful for storing reusable prompt snippets, style templates, or shared trigger word sets separately from any specific LoRA.
Place your .txt files in:
ComfyUI/input/texts/
├── my_style.txt
├── base_prompt.txt
└── ...
5. LoRA Preview Saver (new)
An output node that displays the generated image and provides a one-click button to save it as preview images for connected LoRAs. See LoRA Preview Saver Node above for details.
Installation
Via ComfyUI Manager (recommended)
Search for LoRA Txt Loader in the ComfyUI Manager and install.
Manual
cd ComfyUI/custom_nodes
git clone https://github.com/kwokkakiu233/comfyui-lora-txt-loader
Restart ComfyUI after installation.
Usage
1. Prepare your .txt files
Place a .txt file with the same base name as your LoRA in the same folder:
ComfyUI/models/loras/
├── my_character.safetensors
├── my_character.txt ← trigger words go here
├── subfolder/
│ ├── my_pose.safetensors
│ └── my_pose.txt
The .txt file can contain anything — single tags, comma-separated words, full prompt snippets, whatever works for your workflow.
2. (Optional) Add preview images
Place a .png / .jpg / .webp preview image next to the LoRA file with the same base name:
ComfyUI/models/loras/
├── my_character.safetensors
├── my_character.txt
├── my_character.png ← preview image
Or use the LoRA Preview Saver node to auto-generate preview images from your generated outputs.
3. Add the node
Find it under loaders → LoRA Txt Loader
4. Connect and use
| Input | Description |
|-------|-------------|
| model | Connect from checkpoint loader |
| clip | Connect from checkpoint loader |
| lora_name | Click to open cascade browser and select LoRA |
| strength_model | LoRA model strength |
| strength_clip | LoRA CLIP strength |
| positive_prompt | Auto-filled from .txt; edit freely |
| Output | Description |
|--------|-------------|
| model | Patched model |
| clip | Patched CLIP |
| positive_prompt | Your (edited) trigger words — connect to CLIP Text Encode |
| lora_path | Full path to the loaded LoRA file |
Why a .txt file?
If you train your own LoRAs, you already know what triggers them — the metadata inside the file is often empty or auto-generated garbage. A plain text file is the simplest possible way to keep notes next to a model. No tools required, editable in Notepad, survives any model conversion or re-export.
Requirements
- ComfyUI (Desktop or server version)
- Python 3.x (included with ComfyUI)
- No additional dependencies
License
MIT