smart_word_filter
A custom node for filtering, adding, removing, and processing WD14/Danbooru tags based on saved profiles.
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/negis 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 bothposandneg(e.g.pos | ★ Clothingandneg | ★ Clothingare 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:
- Type or paste your tags.
- Mark the ones you want to keep (positive) and the ones you don't (negative).
- Save the result as a named profile under
posorneg.
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
- Open the extension's
tag_lists/sub-folder (it is created automatically after the first run). - Open the file for that category, e.g.
clothing.txt. - Add your tag on a new line (one tag per line, or several separated by commas; lines starting with
#are comments). - 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
- Copy the
smart_word_filterfolder intoComfyUI/custom_nodes/. - Restart ComfyUI.
- 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 asgreen. - Duplicate tags are removed automatically.
<div dir="rtl">
راهنمای فارسی
فیلتر هوشمند کلمات — ابزار پرامپت / تگ ComfyUI
یک افزونه کوچک برای ComfyUI جهت سازماندهی، فیلتر کردن و جایگزینی تگهای پرامپت با استفاده از پروفایلهای قابل استفاده مجدد. این افزونه به همراه لیست تگهای پیشفرض پوشهمحور (شخصیتها، لباس، فیگور/پوز، پسزمینه، نورپردازی و غیره) ارائه میشود و به شما امکان میدهد پروفایلهای مثبت (Positive) / منفی (Negative) اختصاصی خود را یکبار بسازید و در هر ورکفلویی مجدداً استفاده کنید.
محتویات افزونه
این افزونه دو نود (Node) اضافه میکند:
| نود | کاربرد | | :--- | :--- | | Smart Word Filter | مرکز ساخت و مدیریت پروفایل. لیست تگهای خود را بسازید و به عنوان پروفایلهای مثبت/منفی قابل استفاده مجدد ذخیره کنید. | | Profile Tools (Split / Replace by Profile) | از پروفایلهای ذخیرهشده برای جداسازی یک پرامپت به دو گروه یا جایگزینی برخی تگها با تگهای دیگر استفاده میکند. دارای پیشنمایش زنده و تعاملی است. |
مفاهیم پایه
- پروفایلها (Profiles): یک پروفایل صرفاً یک لیست نامگذاریشده از تگهاست. پروفایلها به دو دسته تقسیم میشوند:
pos: پروفایلهایی که قصد دارید در پرامپت مثبت استفاده کنید.neg: پروفایلهایی که قصد دارید در پرامپت منفی استفاده کنید.- لیبلهای
pos/negصرفاً برای کمک به سازماندهی شما هستند؛ هر دو دسته دقیقاً به یک شکل عمل میکنند.
- پروفایلهای پیشفرض (★): پروفایلهایی که نام آنها با ستاره شروع میشود (مانند
★ Face،★ Clothing،★ Pose) به صورت خودکار از فایلهای متنی روی دیسک ساخته میشوند و هاردکد شده نیستند. از آنجا که عمومی هستند، هم درposو هم درnegظاهر میشوند (مثلاًpos | ★ Clothingوneg | ★ Clothingیک لیست واحد هستند). - بهروزرسانی زنده (Live update): یک فایل تگ را ویرایش کنید (یا فایل جدیدی اضافه کنید) تا پروفایلها به طور خودکار بازخوانی شوند — نیازی به ریاستارت کردن ComfyUI نیست.
نود ۱ — Smart Word Filter (ساخت پروفایل)
از این نود برای تبدیل هر مجموعهای از تگها به یک پروفایل ذخیرهشده استفاده کنید:
- تگهای خود را تایپ یا پیست (Paste) کنید.
- تگهایی که میخواهید نگه دارید (مثبت) و تگهایی که نمیخواهید (منفی) را مشخص کنید.
- نتیجه را به عنوان یک پروفایل نامگذاریشده زیر مجموعه
posیاnegذخیره کنید.
پروفایلهای ذخیرهشده روی دیسک (مستقل از ورکفلو) قرار میگیرند؛ بنابراین در تمام ورکفلوها در دسترس بوده و با ریاستارت برنامه هم باقی میمانند.
نود ۲ — Profile Tools (Split / Replace by Profile)
یک نود با یک کلید تغییر حالت (Operation Switch):
حالت split (جداسازی)
- خروجی ۱ (kept): تگهای ورودی که داخل پروفایل(های) انتخابی وجود دارند.
- خروجی ۲ (rest): بقیه تگها.
در داخل نود، هر کارت تگ (Tag chip) دارای دو دکمه است:
+= میخواهم (حفظ اجباری): این تگ را وارد خروجی ۱ میکند، حتی اگر در پروفایل نباشد.-= نمیخواهم (حذف اجباری): این تگ را وارد خروجی ۲ میکند، حتی اگر در پروفایل باشد.- کلیک مجدد باعث ریست شدن حالت میشود. حالت "نمیخواهم" بر حالت "میخواهم" اولویت دارد.
حالت replace (جایگزینی)
تگهای موجود در پروفایل را از ورودی حذف کرده و تگهای جایگزین شما را به جای آنها وارد میکند.
- خروجی ۱ (result): پرامپت نهایی حاصلشده.
- خروجی ۲ (removed_tags): تگهایی که حذف شدهاند.
insert_at: محل قرارگیری جایگزین را کنترل میکند (در اولین تطابق، در ابتدا، یا در انتها).if_no_match: تعیین میکند در صورت پیدا نشدن هیچیک از تگهای پروفایل چه کاری انجام شود (افزودن به انتها / افزودن به ابتدا / صرفنظر کردن).
حالت mode (در هر دو عملیات)
any_profile: اگر تگ حداقل در یکی از پروفایلهای انتخابی باشد تطابق مییابد (اجتماع).all_profiles: تگ تنها در صورتی تطابق مییابد که در تمام پروفایلهای انتخابی موجود باشد (اشتراک).- میتوانید همزمان تا ۴ پروفایل انتخاب کنید (
profile,profile_2,profile_3,profile_4).
پیشنمایش زنده: نود به محض تغییر هر پارامتر، نتیجه را فوراً پیشنمایش میدهد — نیازی به اجرای کامل ورکفلو نیست. اگر متن از نود دیگری میآید، ورکفلو را یکبار اجرا کنید تا نود آخرین متن را دریافت کند؛ پس از آن پیشنمایش به صورت زنده باقی میماند.
نحوه اضافه / ویرایش کردن تگها
آ) اضافه کردن تگ به لیست پیشفرض (★)
- پوشه فرعی
tag_lists/در افزونه را باز کنید (این پوشه پس از اولین اجرا به طور خودکار ساخته میشود). - فایل مربوط به آن دستهبندی را باز کنید (مثلاً
clothing.txt). - تگ خود را در یک خط جدید اضافه کنید (هر خط یک تگ، یا چند تگ که با کاما از هم جدا شدهاند؛ خطوطی که با
#شروع میشوند کامنت هستند). - ذخیره کنید. تغییرات به صورت زنده اعمال میشوند.
ب) ساخت یک دستهبندی پیشفرض کاملاً جدید
یک فایل جدید مانند animals.txt را درون پوشه tag_lists/ (یا tag_lists_default/) قرار دهید. پروفایل جدید ★ Animals به صورت خودکار ظاهر میشود.
پ) ساخت پروفایل اختصاصی خودتان
از نود Smart Word Filter استفاده کنید، لیست خود را بسازید و آن را زیر مجموعه pos یا neg ذخیره کنید. این پروفایل در منوی کشویی Profile Tools نمایش داده خواهد شد.
روش نصب
- پوشه
smart_word_filterرا در مسیرComfyUI/custom_nodes/کپی کنید. - برنامه ComfyUI را ریاستارت کنید.
- صفحه مرورگر را هارد ریفرش کنید (
Ctrl + F5).
نکات کاربردی
- بررسی تطابق تگها به بزرگ و کوچک بودن حروف حساس نیست و با فاصله (Space) و خط زیر (Underscore) یکسان رفتار میکند (
blue_shirt=blue shirt). - وزنها و پرانتزها مدیریت میشوند؛ برای مثال
(green:1.2)به عنوانgreenتطابق داده میشود. - تگهای تکراری به صورت خودکار حذف میشوند.