EmAySee Global String Reader
A text file on disk, disguised as a global variable — share state between workflows
- text
ComfyUI workflows are stateless - every run starts fresh, and there's no built-in way for one workflow to remember something from a previous run or for two workflows to share a value. This node is a pragmatic answer: it reads a string from a plain text file on disk. "Global" here doesn't mean a variable in memory; it means a file in a location you choose, readable from any workflow that knows the path. Write it from one graph, read it from another. That's a surprisingly powerful primitive for automation.
How it works
Given a path and a file_name, it builds {path}/{file_name}.txt and returns the file's contents as a STRING. Three behaviors from the source are worth knowing:
- It creates the directory if missing. Missing folder isn't an error; it's just created.
- A missing file returns an empty string rather than erroring. That's deliberate and friendly - your first-ever read gets
"", not a red node. - It never creates the file. If the file doesn't exist yet, you get the empty string until a writer (like
EmAySee_GlobalStringUpdater) creates it. So a reader can sit in a workflow and "wait" for state to appear.
Inputs and outputs
path(STRING) - where to look. Default isO:/custom_nodes/storage, the author's own Windows drive. You will want to change this to a path that exists on your machine, likeD:/comfy_stateorComfyUI/user/default/state.file_name(STRING, defaultiteration_state) - the base name;.txtis appended automatically. Don't type the extension.
Output: text (STRING). Wire it into a prompt, a text combiner, or downstream logic.
Where it fits
The author's own use case shows in the default file_name (iteration_state) - running state across generations. Reader/Writer pairs are also how you pass a value between two ComfyUI instances pointing at the same filesystem, or hand a value from an external script into ComfyUI without the API. Note the sibling EmAySee_GlobalStringUpdater writes and keeps an append-only history file ({file_name}-story.txt), so if you want a growing record alongside the current state, use that as the writer.
Install
Part of ComfyUI_EmAySee_CustomNodes. ComfyUI Manager → search "EmAySee" → install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
No dependencies, no models - just file I/O. Restart and you'll see the pack's "SPECTRE v5.0" banner.
Gotchas
The default path is a Windows path that doesn't exist on most machines - change it, or the node quietly creates O:/... as a directory (which on Linux/macOS it will literally try to make at the root, and may fail on). Plain text files mean no locking: if two workflows write the same file simultaneously, last-write-wins. And because reads are cached by ComfyUI's normal node caching, a reader may return stale text until the node re-runs - bump a seed or re-queue if it looks frozen.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | O:/custom_nodes/storage | — |
| file_name | STRING | iteration_state | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |