Nodes/ComfyUI-ZML-Image/ZML_筛选提示词
ComfyUI Node

ZML_筛选提示词

Strip the tags you don't want out of a prompt, and keep them in a separate output

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_筛选提示词
    • 文本
    • Help
    • *过滤*
    文本
    过滤标签

    If you generate with tag-style prompts, you will eventually need a bouncer: a node that looks at the list of tags coming in and kicks out the ones you don't want. That's ZML_TextFilter. You feed it your prompt in one box, a comma-separated list of tags to remove in the other, and it returns the cleaned prompt - with the removed tags still available on a separate output, so you can see exactly what got thrown out.

    The author's own help text uses the perfect example: top box says 1girl,solo,nsfw,, bottom box says nsfw,, and the output is 1girl,solo. The use case is obvious - you want to strip NSFW or other tags out of a prompt before it goes to the sampler, or clean up a prompt that came from somewhere else and carried tags you don't use.

    The inputs that matter

    • 文本 - the text to filter. This is your source prompt, typically from a text node or tag loader.
    • 过滤标签 - the tags to remove, comma-separated. Split on commas, trimmed, exact-match against the individual tags in the input.

    Outputs

    • 文本 - the filtered result, with the offending tags gone.
    • *过滤* - the tags that were removed, kept for your inspection (or to log).
    • Help - a string explaining the node. It's optional; if you don't wire it, nothing breaks.

    The mechanics are a bit more careful than a naive "delete the substring" approach, which is nice: it processes line by line (so multi-line prompts keep their structure), splits each line into tags on both ASCII and full-width commas, removes exact matches from the filter list, and only then rejoins - leaving commas and line endings tidy rather than leaving double commas or mangled joins. It's the difference between "works" and "produces clean output you don't have to re-format."

    Where it fits and what to watch

    Pair it with a ZML text block or tag loader and you've got a poor-man's prompt sanitizer: load a prompt from an image, filter out tags you don't want, encode the rest. The filtering is exact-match on whole tags, so nsfw won't match nsfw_art - if your corpus uses variants, add each one to the filter list.

    There's also a V2 in the pack that filters from category files (anime characters, scenes, clothing…) using a community word list, but this plain version is the one that's immediately useful with no setup. Install via ComfyUI Manager (search "ComfyUI-ZML-Image") or cd ComfyUI/custom_nodes && git clone https://github.com/zml-w/ComfyUI-ZML-Image, restart. Labeled ZML_筛选提示词 in the Chinese-default UI; grab the English patch. No models, no extra deps.

    Categoryimage/ZML_图像/文本

    Inputs (2)

    NameTypeDefaultDescription
    文本STRING
    过滤标签STRING

    Outputs (3)

    NameTypeDescription
    文本STRING
    HelpSTRING
    *过滤*STRING