Nodes/Comfyui-Prompt-Sorter/Illustrious Prompt Sorter πŸ› οΈ
ComfyUI Node

Illustrious Prompt Sorter πŸ› οΈ

Sort your Illustrious tag soup without a PhD in Danbooru

By revisionhiep-createΒ·Created 8 months agoΒ·Updated 8 months agoΒ· 2
Illustrious Prompt Sorter πŸ› οΈ
    • sorted_text
    β—„textβ€”β–Ί

    On an Illustrious or NoobAI checkpoint, prompt order isn't cosmetic. Earlier tags get stronger attention - that's the whole reason 1girl, masterpiece, best quality is the canonical opening instead of the reverse - and once you start hand-writing prompts or pasting in tags from a generator, you lose track of what's sitting where. The Illustrious Prompt Sorter is a one-function node that re-buckets your comma-separated tag soup into the conventional hierarchy, subjects first, quality last, so you don't have to audit the order by eye every time you change a line.

    Quick honesty check before you install: the README claims the node takes a clip input and hands back conditioning, ready to plug straight into a KSampler. That's not what ships. The actual node is a pure text transformer - a string in, a string out. No CLIP touched, no conditioning made. The author's README simply describes a fancier node than the code delivers, which is worth knowing because it changes how you wire it.

    How it sorts

    Mechanically it's a small, readable Python function (one file, no dependencies), and it does three things in order:

    1. Splits on commas, strips whitespace, and drops empty tags.
    2. Deduplicates case-insensitively, keeping the first occurrence's spelling. long hair and Long Hair become one tag, which is genuinely handy for generator output.
    3. Bucket-sorts the survivors against six hand-written Danbooru-ish categories, then reassembles in priority order: subjects (1boy, 1girl, solo, male, female, ...) β†’ scene/environment (outdoors, forest, night, ...) β†’ character traits (hair, eyes, blush, tail, ...) β†’ clothing/accessories β†’ action/pose β†’ style/quality (masterpiece, best quality, absurdres, hdr, ...). Anything that matches none of the keywords lands in a catch-all bucket at the end.

    Two details matter. Matching is substring-based with underscores normalized to spaces, so a weighted tag like (masterpiece:1.3) still lands in the quality bucket - your (tag:1.2) weights survive the trip untouched. And within each bucket the original relative order is preserved, so it won't scramble the two clothing tags you deliberately sequenced. lora:/<lora:...> tokens get pulled out and appended at the very end, always - the README talks about choosing where LoRAs appear, but the code has no such option.

    The one input, the one output

    There's exactly one input and one output here, which makes the node about as frictionless as a Comfy node gets:

    • text (STRING, required) - your comma-separated prompt. It's marked forceInput, so don't expect to type into the widget; feed it from a Text Multiline or a Text Concatenate node if you're merging several sources.
    • sorted_text (STRING) - the reordered string. Wire this into whatever turns text into conditioning for your model: a plain CLIPTextEncode, or in the pack's example workflow, a LoraManager Prompt node. Slap a Preview Text node on it once and you'll see exactly what it did.

    Install

    No requirements.txt, no pip deps, no model downloads - it's pure Python stdlib, so this is the rare install that can't break your environment. In ComfyUI Manager, search for the repo title Comfyui-Prompt-Sorter, or just:

    cd ComfyUI/custom_nodes
    git clone https://github.com/revisionhiep-create/Comfyui-Prompt-Sorter
    

    Then restart ComfyUI and look for Illustrious Prompt Sorter πŸ› οΈ under utils. (The README suggests copying a zipped folder in - ignore that, the git clone is the same thing and keeps it updatable.)

    Where it trips people up

    Keep expectations calibrated and it won't. It is not a full Danbooru taxonomy - it's a handful of keyword buckets, so any niche tag (a specific character, an obscure pose) falls straight into the catch-all and stays wherever it fell. What it reliably gives you is "subjects up front, quality tags in the rear," which is the 80% of ordering that actually matters. The dedup can quietly swallow tags that differ only by case, and since LoRAs always go last, don't use it to try to boost a LoRA's text position. Honestly? For a beginner who keeps writing masterpiece somewhere in the middle of a 40-tag prompt, that alone is worth the five-second install.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    sorted_textSTRINGβ€”