text_loadText
Read prompts, JSON or .md off your disk — or a whole folder at once
- text
- file_paths
- file_names
You keep your best prompts in a text file, or a JSON config your workflow depends on, and you're tired of copy-pasting them into a Text node every run. text_loadText is the fix: it reads a file off your disk and hands the contents to the graph as a plain string. No API, no key, no web server - it's just open() with extra steps, in the best way.
It's one of the prompt utilities in ComfyUI-Apt_Preset, the big "Loader → Controller → Sampler" pack by cardenluo (a Chinese-speaking developer who mostly shares on Bilibili, so expect bilingual-but-Chinese-first tooltips). On English Reddit the pack is basically unheard of, which means no tutorial army - but this node is simple enough that you don't need one.
How it works
Give it a path and a file_type, and it reads the file with UTF-8, falling back to GBK on Windows-era encodings - a genuinely thoughtful touch if any of your files come from a Chinese-locale machine. Pick json or toml and it doesn't just dump raw text: it parses the file and re-serializes it pretty-printed, so downstream string ops get clean output. Everything else is read as-is.
The two toggles do the heavy lifting:
- batch_mode - set it to folder mode and
pathbecomes a directory. It globs every file of the chosen type, sorts by name, and merges them into one big string with===== 开始: <file> =====markers between files. - remove_extension - strips the
.txt/.md/etc. off the names it reports, which is the trick that makes this usable as a prompt-batch loader.
char_limit (0–100000) truncates long reads and tells you it did. Leave it at 0 unless you're guarding against a 40MB log file.
The inputs and outputs that matter
- path - a full filesystem path, not ComfyUI's
input/folder. Quotes around it get stripped, which saves you if you habitually paste from a file manager. - file_type -
text,md,json,js,py,toml. If your path has no matching extension, it'll try appending the right one. - Outputs: text (the file contents), file_paths, and file_names. In single-file mode those last two are the path and the basename; in batch mode they're newline-joined lists - perfect for feeding into a splitter that turns them into per-file prompts.
The text output wires straight into any CLIP Text Encode, or into a text-joining node if you want to prepend a style prefix.
Installing it
It ships with the whole pack, which is a big one - budget for a chunky dependency list (onnxruntime, openpyxl, scenedetect, pandas…). Through ComfyUI Manager, search ComfyUI-Apt_Preset and install. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
Then restart ComfyUI. On Windows you can double-click install.bat to install the requirements.txt deps; if you skipped that, expect import errors from nodes you touch.
Common issues
The failure mode is mostly a bad path: an empty path or a file that doesn't exist raises a hard error and kills the run - the message may be in Chinese (文件不存在). Check you're giving an absolute path, not input/something.txt. And remember the pack's companion installs (ComfyUI-GGUF, Advanced-ControlNet, nunchaku) are for other nodes in the pack - this one needs none of them.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| file_type | COMBO | 6 options: text, md, json, js, py, toml | |
| char_limit | INT | 00–100000 | — |
| batch_mode | BOOLEAN | false | — |
| remove_extension | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| file_paths | STRING | — |
| file_names | STRING | — |