da2el-alandClaude Opus 4.8 2d722c33da feat: Autocomplete Plus 用 CSV の category / count を設定可能に
CSV の category 列(表示色)と count 列(補完優先度)を ComfyUI 設定
(既定 5 / 10000)から変更できるようにする。ComfyUI の number 設定は
float で届くため _csv_int_field で整数化してから書き出す。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 01:33:33 +09:00
2025-04-05 03:42:29 +09:00
2025-02-02 05:24:55 +09:00
2025-02-02 05:24:55 +09:00

D2-PromptSelector-comfyUI

English | 日本語 | 繁體中文

A utility for inserting registered prompts with a single button click.


Features

  • Easy prompt input: Insert a registered prompt with a button click
  • Sample image display: Browse prompts while looking at images
  • Editing: Add, edit, delete, and reorder prompts and categories
  • Search: Real-time search across names and prompts
  • Autocomplete Plus integration: Automatically export registered prompts as a completion CSV
  • Multilingual: Japanese / English / Simplified Chinese / Traditional Chinese (users can add languages)
  • Auto backup: Keeps up to 10 versions by default


Opening Prompt Selector

Open it with the "PS" button at the bottom-left of the screen.

Panel operations

Prompt

Clicking a prompt button inserts the prompt into the text area that was last active.

【TIP】 Right-click (or Ctrl+click) inserts the prompt and then closes the Prompt Selector panel.

DynamicPrompt

Clicking a category-name button inserts every prompt in that category using DynamicPrompt syntax.

Example:
Category: hair color
Registered prompts: black hair blonde hair silver hair
Result: { black hair, | blonde hair, | silver hair, }

※ To use DynamicPrompt syntax, you need a custom node such as comfyui-dynamicprompts.

Switching files (tabs)

Each prompt file is a tab.
You can add tabs by adding files in the edit mode described below.

Select the 🔍 tab to search. Both names and prompts are matched by partial match.

Edit

Enters edit mode (described below).

Reload

Reloads the prompt files and refreshes the prompt list to the latest state.

Sample

Toggles the sample view between shown and hidden. When hidden, the 📌 on prompt buttons is also hidden.


Sample view

A sample image and the prompt text are shown in the sample view on the right side of the panel. You can browse prompts while looking at the images.

Display (hover)

Hovering over a prompt button shows that item's image and prompt in the sample view. The last shown item is kept even after the cursor leaves it.

Pinning the sample view

Hovering over a prompt button shows a 📌 at its right edge. Clicking the 📌 pins that item to the sample view. Pressing the 📌 of another prompt switches the pinned target to it.

To unpin, click the unpin button 🔓 at the top-left of the sample view.

Prompts that have an image

A prompt button whose prompt has a registered image shows a small white dot at its top-left.

Registering a sample image

You can register an image in either of the following ways. Supported formats are png / jpeg / webp (no resizing, no size limit).

  • Direct drop: Dropping an image file onto the image area of the sample view registers it to the currently shown prompt. If an image already exists, it is replaced.
  • Edit dialog: Use the ✏️ button at the top-right of the sample view (available even outside edit mode) to open that prompt's edit dialog, then drop an image onto the image area at the bottom of the dialog. You can also register an image from the image area of the add dialog when adding a new prompt.

Deleting a sample image

The × button at the bottom-right of the thumbnail deletes the image. Deleting a prompt, category, or file also deletes the associated sample image.


Edit mode

Enter edit mode with the "Edit" button on the controller bar. Use "Done" to return.

Adding a prompt

In edit mode, clicking the "+ Add" button opens the add dialog, where you enter:

  • Tab (file): choose an existing one or create a new one
  • Category: choose an existing one or create a new one
  • Name (display name)
  • Prompt (multi-line supported)
  • Image (optional): drop it onto the image area at the bottom of the dialog (png / jpeg / webp)

Editing / deleting a prompt

In edit mode, clicking a prompt button opens the edit dialog. The × shown to the left of each prompt deletes it.
You can also register, replace, or delete the sample image from the image area at the bottom of the edit dialog.

Editing / deleting a category

In edit mode, clicking a category-name button opens the edit dialog, where you can rename it or move it to another file. The × to the left of the category name deletes the whole category (all contained prompts are deleted too).

Deleting a file

In edit mode, the × button to the left of each tab deletes the file. When deleting, you must type the file name exactly in the confirmation dialog (to prevent mistakes).

Renaming a file is done in the sort-order dialog described below.

Sort-order dialog

In edit mode, the "Sort" button opens a tree-view dialog.

  • Displays the three levels File → Category → Prompt as a tree
  • Click a label to open the edit dialog
  • Drag ⋮⋮ to reorder
  • Click x to delete

For users of older versions: editing restriction

The first time you try to enter edit mode, if a prompt file is in the old format (nested levels / mixed arrays), a conversion confirmation dialog is shown. The state before conversion is backed up to the tags_migration/ folder.

Before conversion:

hair:
  color:        # category is multi-level
    black: black hair,
    blonde: blonde hair,
hair style:
  - ponytail    # an unnamed list
  - twintails

After conversion:

hair > color:   # flattened
  black: black hair,
  blonde: blonde hair,
hair style:
  ponytail: ponytail    # becomes a named list
  twintails: twintails

Backup

Immediately before any write operation (add / edit / delete / rename file), a snapshot of the entire tags/ is automatically saved to a tags_bak_YYYYMMDD_HHMMSS/ folder.

  • The number of kept snapshots can be changed with the Backup Count setting (default 10, max 100, 0 to disable)
  • Old backups beyond the limit are deleted automatically
  • Reordering (drag & drop) does not create a backup
  • Migration (old format → new format) is saved to the dedicated tags_migration/ folder (not subject to rotation)

Autocomplete Plus integration (CSV export)

If you have ComfyUI-Autocomplete-Plus installed, registered prompts can be automatically exported as a completion CSV dictionary. You can then call them from the autocomplete while typing, without opening the Prompt Selector panel.

  • It works when the Autocomplete Plus: Export CSV setting is enabled (disabled by default).
  • Each time you add, edit, or delete a prompt, custom_nodes/ComfyUI-Autocomplete-Plus/data/danbooru_tags_d2ps.csv is exported automatically.
  • Nothing happens if Autocomplete Plus is not installed (the data/ folder above does not exist).
  • Disabling the setting deletes the exported CSV.

The name shown in completion (alias) has the form file.category.name, so the same registered name in different files or categories can be distinguished. A browser reload is required for Autocomplete Plus to load the exported CSV.

Display priority and category

Autocomplete Plus shows entries with a higher Count (number of registrations) first. You can adjust the ranking by changing the Autocomplete Plus: CSV Count setting.

Changing the Autocomplete Plus: CSV Category setting changes the display color. According to the Autocomplete Plus documentation, this matches Danbooru.

Target / exclude files

You can export only specific files (tabs) or exclude some of them.

  • Autocomplete Plus: Target Files: Export only the files listed here. If left empty, all files are targeted.
  • Autocomplete Plus: Exclude Files: Exclude the files listed here from export.
  • Separate multiple entries with a comma , (e.g. 人, 服, 構図).

See the "Settings" section below as well.


D2 Prompt Selector text-conversion node

This node is for people who find it tedious to call up prompts from the panel.

It detects special tokens in the input text, converts them into registered prompts, and outputs the result. Instead of clicking buttons on the panel, you can assemble prompts inside the workflow.

  • Converts --{name}-- into the registered prompt
  • Converts @@{category}@@ into the prompts of that category using DynamicPrompt syntax
  • Matching is exact. The delimiters -- and @@ can be changed via inputs (to avoid conflicts with other extensions)

Input

Input Type Description
string STRING Prompt input
e.g. 1girl, --beautiful--, best quality
delete_unmatch BOOLEAN How to handle tokens that could not be converted
True: delete the token
False: keep the token as-is
delimiter STRING Delimiter for normal-conversion tokens
default: --
dynamic_delimiter STRING Delimiter for DynamicPrompt-conversion tokens
default: @@

Output

Output Type Description
string STRING The converted text

Token format

Entering --{name}-- outputs the registered prompt. If multiple prompts are registered under the same name, you can pinpoint one with the full path {tab}/{category}/{name}.

Assume the following file is registered:

# bg.yml (tab name: bg)
quality:
    beautiful: Beautiful lighting, highly detailed environment
place:
    stream: nature, stream, rock, wood
    classroom: classroom, window, curtain, desk, chair, chalkboard
Input  : 1girl, solo, --beautiful--, best quality
Output : 1girl, solo, Beautiful lighting, highly detailed environment, best quality

To pinpoint with a full path, write it as --bg/quality/beautiful--.

Writing a category name as @@{category}@@ outputs the prompts in that category using DynamicPrompt syntax. Likewise, if multiple categories share the same name, you can pinpoint one with the full path {tab}/{category}.

Input  : @@place@@
Output : { nature, stream, rock, wood, | classroom, window, curtain, desk, chair, chalkboard, }

To pinpoint with a full path, write it as @@bg/place@@.

Format reference

Format Conversion
--name-- Searches all tabs in order and converts to the prompt of the first matching name
e.g. --stream--
--tab or category/name-- Searches within the specified tab. If not found, treats the first part as a category name and searches all tabs
e.g. --bg/stream-- --place/stream--
--tab/category/name-- Full-path specification of tab, category, and name
e.g. --bg/place/stream--
@@category@@ Searches all tabs in order and outputs the first matching category in DynamicPrompt syntax
e.g. @@place@@
@@tab/category@@ Full-path specification of tab and category
e.g. @@bg/place@@
  • Searches follow the tab order (sort in __config__.yml) and convert using the first match
  • Matching is exact (beautiful does not match beautiful2)
  • Tokens that contain spaces (e.g. -- bg / quality / beautiful --) are not converted

Editing prompt files directly

You can also edit the prompt files (YAML format) directly.
The files are stored in {ComfyUI install folder}/custom_nodes/D2-PromptSelector-comfyUI/tags/.

対象:
    1girl: 1girl
    1boy: 1boy

年齢:
    ティーン: teen
    ローティーン: early teen
  • Each category is a name: prompt dictionary
  • Names may contain non-alphanumeric characters
  • Nesting of two or more levels and array format are not supported (old-format files show a conversion dialog on first edit)

A prompt that has a registered image takes the value form name: { prompt: …, image: filename }. Image files are stored in prompt_images/.

hair color:
    black hair:
        prompt: black hair
        image: black_hair.webp   # prompt with an image
    blonde hair: blonde hair      # without an image it stays a string

Adding a file

After adding a new YAML file to tags/, append it to sort in __config__.yml.
The order can be changed freely.

# __config__.yml
sort:
    - 人
    - 人_顔
    - 人_髪
    - ポーズ

Changes take effect via the 🔄 button or by reloading ComfyUI.


Settings

The following can be configured from ComfyUI's Settings.

Setting Description
ShowButton Location Reference edge position of the "PS" button
ShowButton Horizontal Margin(px) Horizontal (X) margin from the screen edge
ShowButton Vertical Margin(px) Vertical (Y) margin from the screen edge
Backup Count Number of backups kept (0–100, 0 to disable)
Autocomplete Plus: Export CSV Enable exporting the CSV for Autocomplete Plus
Autocomplete Plus: CSV Count Higher values rank higher (default: 10000)
Autocomplete Plus: CSV Category Changes the display color (default: 5)
Autocomplete Plus: Target Files Files to export (comma separated, empty = all)
Autocomplete Plus: Exclude Files Files to exclude from export (comma separated)

Multilingual support

For supported languages and how to add your own, see docs/i18n_en.md.


Version history

v4.2.0

  • Added settings for exporting the CSV for Autocomplete Plus

v4.1.0

  • Added automatic CSV export for Autocomplete Plus

v4.0.0

  • Added the sample image display feature

v3.0.0

  • Added the text-conversion node

v2.0.0

  • Added prompt editing

License

MIT

S
Description
No description provided
Readme MIT
27 MiB
Languages
JavaScript 56.3%
Svelte 19.1%
Python 15%
TypeScript 4.8%
SCSS 2.7%
Other 2.1%