Text Latch (Persistent)
A text node that remembers the last prompt — even after ComfyUI restarts
- text
ComfyUI is a graph of pure functions: every node runs, passes a value down the wire, and forgets it ever happened. Most of the time that's the point - deterministic, re-runnable, no surprises. But sometimes you want a node with a memory, and that's the entire pitch of Text Latch (Persistent). It stores the last non-empty piece of text you fed it and hands that back whenever its input goes quiet. Not just for the rest of the queue run - across ComfyUI restarts, too.
Why you'd reach for it
The case that actually sells this thing: your prompt doesn't always come from your fingers. Once you wire text from an LLM node, a switch, a Text Concatenate, or an API-fed queue, you will eventually get an empty string - a model that returned nothing, a branch you didn't fill in. Queuing an empty prompt isn't just wasted time; on some models it quietly produces garbage. Text Latch sits between the flaky source and your CLIP Text Encode and says "blank? here's the last good one."
It also works as a poor man's prompt history. name a latch, feed it your working prompt, and that text survives restarts - so a workflow reopened next week can still hand you what you were iterating on, no notes file required. Because the stored value is keyed by name on disk, two different workflows that share a name can even pass text between them: workflow A saves a prompt under myproject, workflow B with an empty text_in and the same name picks it right up.
How it actually works
The logic is short enough to read in one sitting. On every execution the node checks text_in:
- If it's non-empty, the text is written to disk under your
nameand passed straight through the output. - If it's empty or the wire is disconnected, the node reads the last stored text back and returns it instead.
- If nothing has ever been stored under that name, it returns an empty string.
Storage is a tiny JSON file per name, written atomically (temp file + rename, thread-locked) under your ComfyUI user directory in history-tools/text-latches. That disk backing is the whole trick - it's why the state survives restarts where "workflow variable" nodes in other packs evaporate the moment ComfyUI exits. No API, no key, no model file; this pack has literally zero dependencies, pure Python stdlib.
The inputs and the one output
There are exactly two knobs:
name(required, defaults to"default") - the cache key. Give every latch a descriptive name; more on why below.text_in(optional) - the text to remember. Feed it from any text-producing node, or leave it unwired.
The single text output is a plain STRING, so it plugs into anything that takes a prompt - CLIP Text Encode positive or negative, Flux-style text encoders, or another text node's input. It's not an output node, so don't expect it to display anything on its own; it just holds its value and moves text around while the graph runs.
Installing it
Via ComfyUI Manager, search Text Latch by Jashi (the registry author id), install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Jasshl/ComfyUI-Text-Latch.git
Restart ComfyUI after cloning. The node appears under the history tools category, and there's nothing else to download - no weights, no pip installs.
Gotchas that will bite you
- Names are shared across every workflow on your machine. Two workflows both lazily using the default
"default"will clobber each other's memory. Use project-scoped names and you're fine. - You can't intentionally store an empty prompt. Empty input means "read memory," not "clear memory." To reset a latch, delete its JSON file under
ComfyUI/user/history-tools/text-latches/(filenames are name-based, so the right one is findable) or just switch to a fresh name. - The memory doesn't travel with the workflow. Stored text is deliberately excluded from exported workflow JSON, so a shared workflow starts cold on a new machine - it returns
""until something feeds it. That's a feature (no secrets leaking into shared files), but it surprises people. - Don't bypass the node and expect it to keep holding. A bypassed node doesn't execute, so nothing gets stored or read while it's muted.
Is this a must-have? Honestly, no - most people never miss it. But it's a fifty-line utility that quietly saves a batch run the first time a flaky text source goes blank, and it's one of the only text nodes in the ecosystem that actually persists across restarts. If you've ever cursed a workflow for queuing an empty prompt, you now know what it was missing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | default | — |
| text_inopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |