# Smart Word Filter — ComfyUI Prompt / Tag Toolkit
A small ComfyUI extension for organizing, filtering, and swapping prompt tags using reusable profiles. It ships with folder-based built-in tag lists (characters, clothing, pose, background, lighting, etc.) and lets you build your own positive / negative profiles once and reuse them in any workflow.
---
## What's inside
The extension adds two nodes:
| Node | Purpose |
| :--- | :--- |
| Smart Word Filter | The profile authoring hub. Create and save your own tag lists as reusable pos / neg profiles. |
| Profile Tools (Split / Replace by Profile) | Uses saved profiles to split a prompt into two groups, or replace some tags with others. Has a live, interactive preview. |
---
## Core concepts
* Profiles: A profile is just a named list of tags. Profiles are grouped into two kinds:
* pos: Profiles you intend to use with your positive prompt.
* neg: Profiles you intend to use with your negative prompt.
* pos / neg is only a label to help you organize; both kinds work exactly the same way.
* Built-in (★) profiles: Profiles whose name starts with a star, such as ★ Face, ★ Clothing, ★ Pose, are built automatically from text files on disk — they are not hard-coded. Because they are generic, they appear under both pos and neg (e.g. pos | ★ Clothing and neg | ★ Clothing are the same list).
* Live update: Edit a tag file (or add a new one) and the profiles refresh automatically — no need to restart ComfyUI.
---
## Node 1 — Smart Word Filter (profile authoring)
Use this node to turn any set of tags into a saved profile:
1. Type or paste your tags.
2. Mark the ones you want to keep (positive) and the ones you don't (negative).
3. Save the result as a named profile under pos or neg.
Saved profiles live on disk (independent of the workflow), so they are available in every workflow and survive restarts.
---
## Node 2 — Profile Tools (Split / Replace by Profile)
One node with an operation switch:
### operation = split
* output 1 (kept): The input tags that are inside the selected profile(s).
* output 2 (rest): Everything else.
In the node, every tag chip has two buttons:
+ = *want (force-keep):** Push this tag into output 1 even if it isn't in the profile.
- = *don't want (force-remove):** Push this tag into output 2 even if it is in the profile.
* Click again to reset. "don't want" wins over "want".
### operation = replace
Removes the profile tags from the input and inserts your replacement tags in their place.
* output 1 (result): The resulting prompt.
* output 2 (removed_tags): The tags that were removed.
* insert_at: Controls where the replacement goes (at the first match, at the start, or at the end).
* if_no_match: Controls what to do when none of the profile tags were found (append / prepend / skip).
### mode (both operations)
* any_profile: A tag matches if it is in at least one selected profile (union).
* all_profiles: A tag matches only if it is in every selected profile (intersection).
* You can select up to 4 profiles at once profile, profile_2, profile_3, profile_4).
Live preview: The node previews the result instantly as you change anything — you don't have to run the whole workflow. If the text comes from another node, run the workflow once so the node knows the latest text, then the preview stays live.
---
## How to add / edit tags
### A) Add tags to a built-in (★) list
1. Open the extension's tag_lists/ sub-folder (it is created automatically after the first run).
2. Open the file for that category, e.g. clothing.txt.
3. Add your tag on a new line (one tag per line, or several separated by commas; lines starting with # are comments).
4. Save. The change applies live.
### B) Create a brand-new built-in category
Drop a new file like animals.txt into tag_lists/ (or tag_lists_default/). A new ★ Animals profile appears automatically.
### C) Create your own profile
Use the Smart Word Filter node, build your list, and save it under pos or neg. It will show up in the Profile Tools dropdown.
---
## Installation
1. Copy the smart_word_filter folder into ComfyUI/custom_nodes/.
2. Restart ComfyUI.
3. Hard-refresh the browser page Ctrl + F5).
---
## Tips
* Tag matching ignores case and treats spaces / underscores the same blue_shirt = blue shirt).
* Weights and brackets are handled, e.g. (green:1.2) is matched as green.
* Duplicate tags are removed automatically.
---
---
<div dir="rtl">
</div>
<img width="1048" height="610" alt="Screenshot (1996)" src="https://github.com/user-attachments/assets/a3dc6f72-47cc-41e8-9fb3-4870b7ac3a57" />
<img width="1053" height="571" alt="Screenshot (1997)" src="https://github.com/user-attachments/assets/056bf4fd-645b-4266-a80d-ce164074885a" />

