ComfyUI Node
Prompt Cleaner (CLIP Text Encode)
Cleans the prompt with Prompt Cleaner rules and then encodes it with CLIP. One output goes straight to the sampler as CONDITIONING, the other exposes the cleaned text for reuse or inspection.
Prompt Cleaner (CLIP Text Encode)
- clip
- extra_texts
- conditioning
- cleaned_text
◄text►
◄bracket_policy仅转义圆括号(推荐)►
◄keep_weightstrue►
◄underscore_to_spacetrue►
◄dedupetrue►
◄strip_blacklisttrue►
◄lowercasefalse►
◄separator逗号 + 空格►
◄normalize_fullwidthtrue►
◄blacklist# ===== Prompt Cleaner 默认黑名单 =====
# 每行一条规则;# 开头为注释;清空本框 = 关闭黑名单过滤。
# 普通标签:忽略大小写、忽略空格/下划线差异,做「整标签」匹配。
# 正则规则:以 re: 开头,做包含匹配(如需整标签匹配请用 ^...$ 锚点)。
# --- Danbooru meta / 水印 / 署名类 ---
tagme
watermark
sample watermark
signature
username
twitter username
patreon username
artist name
web address
bad id
bad source
dated
logo
# --- 纯文字 / 对话框 / 翻译标注类 ---
english text
translated
check translation
speech bubble
commentary
# --- 请求类站位标签(对出图无意义) ---
artist request
character request
reference request
# --- 年份标签,如 year 2024 ---
re:^year\s+\d{4}$
►
◄text_in—►
CategoryPrompt Cleaner
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | CLIP / text encoder used to encode the prompt (Anima uses qwen_3_06b_base). | |
| text | STRING | Paste raw tags here: comma separated, one tag per line, or a mix of both. When 'text in' is connected, this box is appended after it (and after any extra text sockets), so you can mix an upstream prompt with extra tags typed here. Leave it empty to use only the sockets. | |
| bracket_policy | COMBO | 仅转义圆括号(推荐) | Bracket escaping policy. - Escaped parentheses only (recommended): sunna (zenless zone zero) -> sunna \(zenless zone zero\). In ComfyUI only \( \) is a real escape sequence (see escape_important in comfy/sd1_clip.py). - Escape everything: also backslash-escape square and curly brackets. Note that [ ] { } are NOT syntax in ComfyUI, so \[ \] \{ \} is never unescaped and the backslash ends up as a literal character for the Qwen2 tokenizer. - Leave as is: no escaping at all. Explicit weights such as (tag:1.2) are handled by the separate 'keep_weights' toggle, not by this policy. |
| keep_weights | BOOLEAN | true | Preserve explicit weight syntax: masterpiece, (best_quality:1.3) -> masterpiece, (best quality:1.3) A bracket group ending in :number is treated as a weight and kept as is so ComfyUI can parse it normally; all other brackets (such as the character series in 'sunna (zenless zone zero)') are escaped as usual. Nested weights such as ((tag:1.2)) are preserved too. Turn this off to escape every parenthesis, which would degrade (masterpiece:1.2) into \(masterpiece:1.2\) and drop the weight. |
| underscore_to_space | BOOLEAN | true | Convert underscores to spaces: drawing_bow -> drawing bow; sunna_(zenless_zone_zero) -> sunna (zenless zone zero). |
| dedupe | BOOLEAN | true | Drop repeated tags (case-insensitive, leading and trailing whitespace ignored), keeping the first occurrence. |
| strip_blacklist | BOOLEAN | true | Drop dirty tags such as tagme / watermark / signature using the blacklist below. |
| lowercase | BOOLEAN | false | Lowercase every tag, matching the Anima community convention of lowercase multi-word tags. |
| separator | COMBO | 逗号 + 空格 | String used to join the tags. '逗号 + 空格' = comma followed by a space (default, recommended); '仅逗号' = bare comma. |
| normalize_fullwidth | BOOLEAN | true | Convert full-width punctuation and full-width spaces to their half-width equivalents, e.g. () -> () and _ -> _. |
| blacklist | STRING | # ===== Prompt Cleaner 默认黑名单 ===== # 每行一条规则;# 开头为注释;清空本框 = 关闭黑名单过滤。 # 普通标签:忽略大小写、忽略空格/下划线差异,做「整标签」匹配。 # 正则规则:以 re: 开头,做包含匹配(如需整标签匹配请用 ^...$ 锚点)。 # --- Danbooru meta / 水印 / 署名类 --- tagme watermark sample watermark signature username twitter username patreon username artist name web address bad id bad source dated logo # --- 纯文字 / 对话框 / 翻译标注类 --- english text translated check translation speech bubble commentary # --- 请求类站位标签(对出图无意义) --- artist request character request reference request # --- 年份标签,如 year 2024 --- re:^year\s+\d{4}$ | Blacklist rules, one per line: - blank lines, and lines starting with #, are comments; - plain text = whole-tag match (case-insensitive, spaces and underscores treated as equal), e.g. watermark; - re: prefix = regular expression, partial match, e.g. re:^year\s+\d{4}$. Clear this box to disable blacklist filtering entirely. |
| text_inopt | STRING | Optional STRING socket. Whatever arrives here is cleaned first, then the extra text sockets (if any) and the content of the 'prompt text' box below are appended right after it and cleaned together. Leave it unconnected to clean the other sources alone. | |
| extra_textsopt | COMFY_AUTOGROW_V3 | Extra text inputs. - Connect a socket to make the next one appear (up to 10 extra sockets); - or use the '+ text input' button on the node / the settings window to add or remove sockets by hand. Everything that is connected is concatenated in order (text in -> extra inputs -> prompt text box) and cleaned as one prompt, so dedupe and blacklist also work across sources. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| conditioning | CONDITIONING | Encoded conditioning of the cleaned prompt, ready for a sampler. |
| cleaned_text | STRING | Cleaned single-line prompt, for reuse or for double-checking. |