Dynamic Load Text File Node
Read any text file from disk — and auto-reload when you edit it
- content
- exception
A text-file reader sounds like the most boring node in the pack, and it sort of is. But it's also the one that makes DynamicScriptNode usable, and it has a party trick worth stealing: it notices when the file changes on disk and reruns automatically.
The intended workflow is right there in the pack's README. You don't type Python into the script node's fragile code box - you edit a .py file in VS Code, load it with this node, and feed the content output into the script node's code input. Edit, save, hit Run in ComfyUI, and the new script executes. No copy-paste, no "did I refresh and lose my code again."
That works because of how the node detects changes. Give it a file_path and it reads the file and computes an MD5 of the content; its change-detection compares that hash each run, so the node (and whatever hangs off it) only re-executes when the file actually changed. Leave the file alone and it's cheap. Touch it and the whole branch refreshes.
The inputs and outputs that matter
Only two inputs, and you'll set both:
file_path- the full path to the file, e.g.E:/dir/script.pyor/home/you/prompts.txt. Not relative to ComfyUI's folders; it's a raw disk path.encoding- a dropdown of 90 text encodings, defaultutf_8. If you read a lot of CJK files you'll appreciate having GBK etc. on tap instead of mojibake.
Outputs:
content- the file contents as a STRING.Noneif reading failed.exception-Noneon success, otherwise the error (file not found, not a file, permission denied). Wire this into a Display Any node if you want to see failures on canvas instead of a silentNone.
Where people get burned
- It's not a magic auto-watcher mid-run. The change detection works between queue runs, not while a run is executing. You edit, you run, it reloads - you don't get live reload during a batch.
- Wrong encoding usually self-heals. The reader tries your chosen encoding first, then falls back through the other text encodings before giving up. So an odd file often still loads - but it's worth knowing the
exceptionoutput only fires on hard failures, not on encoding fallback. - A nonexistent path gives you
content = Noneplus an exception, not a crash. If something downstream is silently empty, check theexceptionoutput.
When to reach for it
Beyond feeding the script node, it's the easy way to get a prompt list, a JSON config, or a wildcard file off disk and into the graph as a plain string - no node pack that only does JSON, only does prompts, etc. It's the generic one. Give it a path, pick an encoding, and you're done. It's the node I'd install the pack for even if I never wrote a line of script code.
Install is the whole pack, zero dependencies:
cd ComfyUI/custom_nodes
git clone https://github.com/inkbottle-9/comfyui_dynamic.git
then restart ComfyUI - or search comfyui_dynamic in ComfyUI Manager's install menu. It's a small, solo-maintained, LGPL pack, so expect rough edges, but this particular node is about as simple as a node gets.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | The full path to the text file to load. (e.g. E:/dir/script.py) | |
| encoding | COMBO | utf_8 | The encoding to use for reading the file. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| content | STRING | The content of the file. |
| exception | * | Exception information or None. |