ReadFileToString(NYJY)
Pull any text file into your workflow as a string
- STRING
Most ComfyUI text lives inside the graph, which is great until you want to reuse the same prompt across ten workflows or version it in git. ReadFileToString is the escape hatch: give it a file path and it hands you the file's entire contents as a string you can drop into any text input in the graph.
It's one of the small logic nodes in ComfyUI_NYJY, a Chinese pack by aidenli that's best known for its JoyTag/JoyCaption captioning and its cloud-API wrappers. The logic corner of the pack is where you find the boring-but-useful stuff: JSON parsing, string splitting, file reading. This node is about as simple as a node gets, so treat it as a building block rather than a feature.
How it works. One input, file_path (a single-line string), one output, STRING. The node opens the file as UTF-8 and reads it whole - open(file_path, 'r', encoding="utf-8") - and pushes the text out. That's the mechanism, full stop. The interesting bit is what you do with the string once it's in the graph: feed it to a JsonLoads node to parse a config file, pipe it into a prompt field for long reusable prompts, or hand it to a chat node as context. Since this pack's VolcengineChat takes plain strings, a file of instructions or a prompt library becomes a real data source instead of a copy-paste chore.
The trap. If the file can't be read - wrong path, missing file, or (most commonly) a path with a backslash or space that didn't survive the journey from Windows Explorer - the node doesn't throw. It returns the error message itself as the string output. So your "prompt" suddenly becomes "No such file or directory: ...", which then flows into whatever you wired it to, and you'll spend a while wondering why the model is generating the text of an exception. If you see that, the fix is a full, valid absolute path, and remember UTF-8 encoding - anything else (like a UTF-16 file from a Windows editor) reads as garbage or fails.
Install. The node ships inside the whole NYJY pack, so you install the pack, not the node:
cd ComfyUI/custom_nodes
git clone https://github.com/aidenli/ComfyUI_NYJY
restart, and run pip install -r requirements.txt (or use ComfyUI Manager's "Install via Git URL" with https://github.com/aidenli/ComfyUI_NYJY). For this node specifically there are zero dependencies - it's pure Python stdlib. The heavyweight requirements in the pack are for its captioning and translation nodes, so if you only care about the logic tools you can often get away with a partial install, though a full install.bat on Windows is the path of least resistance.
When to reach for it. When a prompt, list, or config lives in a file and you're tired of retyping it. It's the "load from disk" half of a workflow; pair it with SplitString when the file holds many prompts, or JsonLoads when it holds data.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |