ZML_删除文本
Scrub unwanted tags out of a prompt without mangling the rest
- 文本
- Help
A text node for when your prompt is polluted: you have a big prompt string, you want 2girls gone, you want solo gone, and you don't want to hand-edit a monster prompt every time you swap a tag. This node removes tags or substrings from the first text based on a comma-separated list in the second, then tidies up the leftover comma soup so the result stays clean.
How it works
Straightforward string surgery. It splits your delete-list on commas, strips whitespace, and removes every entry from the source text using plain replace(). Then it collapses runs of commas into one, and trims stray leading/trailing commas. The author's own help text gives the exact example: source #1girl,2girls,solo, with deletes 2girls,#,1,o, comes out girl,sl, - which is also the perfect illustration of the node's sharpest edge: it removes substrings, not whole tags. Deleting 1 and o guts the middle of other tags. Short delete strings are a footgun.
So the mental model is: this is substring filtering plus comma hygiene, not a tag-aware "remove these full tags" tool. If your deletes are full tag names like 2girls,solo,nsfw, you're golden. If they're single characters, read the warning above again.
The inputs
- 文本 - the source string, multiline. Empty in, empty out.
- 删除标签或字符 - the comma-separated list of substrings to remove.
Outputs: 文本 (the cleaned string) and Help, which just echoes the author's usage note. Wire the cleaned text straight into a CLIP Text Encode or a ZML text-block node.
Installing
The pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
restart, or install through ComfyUI Manager. It's pure Python string work - no extra dependencies beyond the pack base. English UI comes from the translation patch (https://github.com/zml-w/ZZZ_ZML_English_Patch).
Common issues
The substring trap is the one to internalize. Deleting a short string like red will happily remove red from hundred, sacred, or tired - the node doesn't know or care. If you need whole-tag deletion, put delimiters in your delete list (like ,red,), or use a proper tag-filtering node. Second, order matters: deletes run in list order and each one operates on the previous result, so overlapping deletes can interact in non-obvious ways. Third, it's comma-hygiene only - if your prompt uses other separators (newlines, BREAK), the cleanup won't touch them. Fine for the standard comma-joined tag format, less so for structured prompts.
That said, for its niche it's quietly great: filter a prompt before sending it to a negative encoder, strip an artist tag you're swapping out, or clean the output of a LoRA-tag loader before it hits the sampler.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| 文本 | STRING | — | |
| 删除标签或字符 | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 文本 | STRING | — |
| Help | STRING | — |