Prompt Library
Stop doing copy-paste archaeology in your prompt box
- prompt
What this is, and the itch it scratches
ComfyUI's node graph solved repetition for numbers and models: one seed primitive feeds five samplers. Then you get to the prompt, and you're back to a text field you retype and re-derive from memory every session. So people keep a Notepad file open on a second monitor and paste.
Prompt Library replaces the Notepad file. Each prompt fragment becomes its own line you can toggle, group, reorder, and nudge with a weight slider, and you save the whole arrangement as a named template to reload instead of rebuilding. It touches no pixels - a plumbing node in the strict sense, fighting the third kind of repetition, the one that isn't a number: the same phrasing you've tuned by hand over months.
How it actually works
The whole mechanism lives in one required input, prompt_state, a STRING holding JSON - the widget the node's custom panel writes to as you click around. At execution time the node parses that JSON and does one thing: for every enabled, non-empty line it appends the text, or (text:1.2) if the weight isn't 1.0, joined with a separator you pick.
Groups are just a marker row in that line list. A group entry sets an enabled flag for every line below it until the next group, which is how you mute "lighting" without clicking ten lines. Weights round to one decimal and clamp between 0.1 and 3.0.
The part worth internalising: at runtime the node never reads your template files. Templates live as a .json plus a human-readable .txt in custom_nodes/comfyui-prompt-library/templates/, JSON being the source of truth - but what reaches your sampler is the widget value baked into the workflow. So editing characters/girl.json on disk does nothing to a loaded graph, and sharing the workflow shares your lines whether you meant it or not.
The inputs and output that matter
text_in is optional and is the interesting one: it's declared forceInput, so it exists only as a socket. Wire a STRING into it and the node prepends that text to its own prompt, using the same separator. The frontend grows text_in_2, text_in_3 and so on as you connect them, so you can chain one Prompt Library into the next - subject template, then style template. Order is text_in, then text_in_2 upward, then the node's own edited lines.
The output is a single prompt STRING. Wire it into a CLIP Text Encode's text input - right-click that widget and "Convert to input" first on an older frontend. A negative prompt needs a second copy of the node.
Two panel settings deserve a decision rather than a default. Keep the separator on newline if you write sentences, but switch it to , for booru-style tags, because comma placement matters there. And the weights: they work on SD 1.5, SDXL, Illustrious, NoobAI and Pony, practical range about 0.5–1.5, above which you get oversaturation and distortion. On an LLM-encoded model - Z-Image, Flux 2 Klein, Anima, Krea 2, ERNIE - attention weights are discarded by the encoder entirely, so the sliders are cosplay. The node still emits (red hair:1.2); the model won't read it, and that punctuation lands in your instruction as literal text, which is worse than nothing.
Installing it
It's on the Comfy Registry under publisher anogpt with no Python dependencies, no requirements.txt and no model downloads - Python plus a JS panel, and everything it imports already ships with ComfyUI. In ComfyUI Manager, search Prompt Library. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/anogpt/comfyui-prompt-library
Then fully restart ComfyUI.
Where people get burned
Your library lives inside the pack folder. Every template JSON sits in custom_nodes/comfyui-prompt-library/templates/, so anything that wipes or re-clones that directory takes your tuned prompt set with it. Back up templates/ before updating. The .txt is a one-way export - restoring from one means Import, then save.
Import is deliberately conservative. (red hair:1.2) gets normalized into the line text and weight fields, but nested syntax like ((red hair)) is left as raw text, and a leading // marks a line disabled. Right call - but your old A1111 prompt pastes in with the double-parens still in it. Clean those by hand; they stack into artifacts.
Nothing happens when you toggle a line. Three usual causes: the output isn't wired to the encoder and you're editing a leftover text widget; the change is in the panel but not yet in the saved widget; or you're on an LLM-encoded model and the line you toggled was a weight.
The panel is custom UI, and custom UI is the ecosystem's fragile part. The Nodes 2.0 frontend rewrite broke rendering for UI-heavy third-party packs. If this editor draws wrong, try the legacy canvas first.
One last thing, given what a library like this holds: your prompt rides in the PNG metadata of every image you save. Share the picture and you share the prompt - including the lines you kept because they were your edge.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt_state | STRING | {"path": "", "separator": "\n", "input_count": 1, "lines": [{"kind": "line", "text": "masterpiece", "enabled": true, "weight": 1.0}]} | — |
| text_inopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |