D2 Load Text
Read a text file into the graph, with encoding rescue built in
- text
- file_path
D2 Load Text is a general-purpose "read a text file into the graph" node. Give it a file_path and it outputs the file's contents as a STRING you can pipe into a prompt, a filename template, a caption cleaner, or anything else that eats text. It's the file-reader the D2 pack uses as the input half of its caption-editing story, and it's about as boring and reliable as a node can get.
Where it actually gets interesting is the loop the author built it for: batch caption editing. Chain a D2 Folder Image Queue pointing at a folder of *.txt caption files into this node, and each queued run reads the next caption file automatically. The node even tracks the file's modification time and re-runs if the file changes on disk between executions - so you can edit a caption in an external editor and have the workflow pick up the change without a manual refresh.
The inputs
file_path- full path to the text file.encode_to_utf8- the rescue switch. Defaultfalsereads the file as UTF-8. Turn it on and the node auto-detects the character encoding and converts to UTF-8 for you - a genuine lifesaver with caption files saved by random Windows tools or legacy Japanese-encoded data.
Outputs
text- the file's contents. Returns an empty string if the file doesn't exist, rather than crashing - deliberate, so a missing caption just yields an empty prompt.file_path- the input path passed through, ready to feed abase_filenameon D2 Save Caption.
Installing it
ComfyUI Manager → search "D2-nodes-ComfyUI" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/da2el-ai/D2-nodes-ComfyUI
Restart. No model downloads; deps are piexif and charset-normalizer (and yes, charset-normalizer is exactly what powers that encoding detection). Since v32.0.0 the pack targets ComfyUI's V3 schema - older ComfyUI builds should pin before 32.0.0.
The honest caveats
"Returns an empty string instead of erroring" cuts both ways: a typo'd path silently produces an empty prompt, and you might not notice until the output looks wrong. If your workflow depends on the file actually loading, keep an eye on the text output. And while the mtime fingerprinting is neat, it means external saves mid-queue can change what a later run reads - for batch work, set the files down before you queue, then edit after.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| encode_to_utf8 | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| file_path | STRING | — |