Filter Prompt by TXT File
Filter a prompt against a TXT file — the node that reads your keyword list
- STRING
The whole ComfyUI-prompt-filter-nodes pack exists to mark specific keywords in a prompt - stamp # on characters, @ on artists - so you can swap and filter them later. This node is where that workflow starts: it reads a plain TXT file of keywords, splits your prompt on commas, and keeps only the tags that are in that file. In other words, it's how your prompt tells you which tags you cared enough about to list.
It's the entry point of a four-node pipeline. Feed its output into Apply Multiple Prefixes to Keywords (as the filtered_keywords_list), use Concatenate Strings (Multi) to assemble the matching prefixes, and you've built the author's example workflow without writing a line of code. The pack is pure Python with zero dependencies - no models, no API, no pip install - just string handling.
How it works
Read the source and it's a clean little story:
- It checks the
file_pathexists. If it doesn't, you get an empty string and a warning in the console - the node fails soft, not hard. - It reads the file with encoding auto-detection, trying
utf-8,gbk,gb2312,shift_jis, thenlatin-1in order. That's a thoughtful touch: the author is Chinese, and it means a GBK-encoded list works without you ever opening a hex editor. It's the first thing that tells you this pack was built for a specific userbase. - Every non-empty line becomes a keyword (one entry per line, exactly like the README insists).
- Your
prompt_textis split on commas, stripped, and compared against that keyword set. Matching is exact string equality -hatsune mikuin the file matches the taghatsune miku, nothatsune miku smiling.
What comes out is the matching tags, joined together.
The inputs that matter
prompt_text- your full prompt, the thing being filtered.file_path- an absolute path to the TXT file. The README is explicit: Windows absolute paths are what the author uses, and the format is one keyword per line, no extra formatting. A relative path or a file with keywords on the same line will quietly give you nothing.join_with_comma- boolean. True (default) joins the found tags with commas; False joins them with spaces. Keep it on if the output is going into another tag-splitting node.
The single output is a STRING. If nothing matched, it's an empty string.
Where people get burned
Three classics, all grounded in the mechanism:
- Wrong path. The file isn't found → empty output, and the only hint is a console warning. Double-check the path is absolute and the filename is right.
- Exact-match only. The file says
twin_tails, your prompt saystwintails, you get nothing. Line endings and trailing spaces also count - the node strips line whitespace, but not spaces inside a line. - Encoding edge cases. Auto-detection handles the common cases, but
latin-1as a last resort means a badly-broken file can "decode" into mojibake that then never matches anything. If a file silently returns empty, try re-saving it as UTF-8.
Installing it
It's on the Comfy Registry, so the easy route is ComfyUI Manager: search "ComfyUI-prompt-filter-nodes" (or "prompt filter"), install, restart. Or clone it directly:
cd ComfyUI/custom_nodes
git clone https://github.com/GHOSTLXH/ComfyUI-prompt-filter-nodes
Then restart ComfyUI. There's no requirements.txt and no install.py - the pack imports only Python's standard library, so there are no heavy dependencies and no model files to hunt down. If the node doesn't show up after a restart, the clone isn't directly inside custom_nodes, or you didn't restart the server fully.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt_text | STRING | 1girl, solo, masterpiece, best quality, red dress, smiling, beautiful detailed eyes | — |
| file_path | STRING | C:\path\to\your\keywords.txt | — |
| join_with_comma | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |