Nodes/Tag Limiter/Tag Limiter
ComfyUI Node

Tag Limiter

Stop cramming 80 tags into a prompt that wants 40

By scofano·Created 6 months ago·Updated 5 months ago· 0
Tag Limiter
    • STRING
    text
    limit40

    The name is honest - it trims your tag list

    Tag Limiter does exactly one thing: it takes a comma-separated string, keeps the first N tags, and hands you back a tidy string. No API calls, no model downloads, no config files. It's a ~20-line Python node that exists for one very real workflow problem: wildcard and dynamic-prompt systems love to vomit out 60-tag lists, and most models genuinely do not want that many.

    On the SDXL-lineage models most people still run - Illustrious, NoobAI, Pony, plain SDXL - your prompt hits a hard 77-token CLIP boundary, and tags past it get truncated or ignored entirely. On top of that, earlier keywords receive stronger attention than later ones. So a huge tag list isn't just wasteful, it's actively dragging your composition toward whatever junk landed at the end. Capping the list to the tags that matter - and keeping them first - is a legitimate quality move, not just tidiness. Tag Limiter is the cheap way to do it.

    How it works

    The mechanism is short enough to read in full, and it's worth knowing because it explains every edge case:

    • If the whole input is wrapped in double quotes, it strips them for processing and re-adds them at the end.
    • It splits on commas, strips whitespace off each tag, and drops empty entries (so trailing commas don't produce a phantom "" tag).
    • It keeps tags[:limit] - the first N tags, in order.
    • It joins back with ", ".

    That's the whole thing. No sorting, no deduping, no weighting, no token counting. Which is both its charm and its trap, see below.

    The inputs that matter

    There are only two, and both are right there on the node:

    • text - the comma-separated tag string. It's a multiline box, so pasting a big wildcard output works fine. You'll almost always feed this from an upstream node (see "Convert widget to input" in ComfyUI's node plumbing) rather than typing it.
    • limit - how many tags to keep, default 40, range 0–1000. 0 yields an empty string, which is occasionally useful for gating a branch.

    The output is a single STRING. Wire it into the text input of a CLIP Text Encode (Prompt) node (convert that node's text widget to an input first), and you've got a self-trimming prompt.

    Install

    ComfyUI Manager has it as comfy-tag-limiter; search that and click install. Or the manual route:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/scofano/comfy-tag-limiter
    

    Then restart ComfyUI. That's it - the package declares zero dependencies and needs no model files. It shows up in the node browser under the tag_limiter category.

    The honest caveats

    Tag Limiter counts tags, not tokens. Five tags can still blow past the 77-token CLIP boundary if they're long, so treating limit=40 as "this is token-safe" will disappoint you. It's a blunt instrument for taming wildcard messes, not a precision token budget. If you need real token control you want a token-counting node; this one just stops the bleeding.

    Also remember the "first N" rule cuts from the end. Put your most important tags at the front of the list - quality tags, subject, key composition - and let it lop off the tail. That aligns perfectly with how CLIP attends to earlier keywords, so the node rewards you for ordering your prompt well in the first place.

    One genuinely weird thing: the README claims an MIT license, but the repo actually ships AGPL v3. Worth knowing if you're building a commercial pipeline and actually care about license hygiene - the AGPL's network-source clause can matter there.

    Troubleshooting

    • Empty output - you passed empty text, or limit is 0. Check which.
    • Quotes still showing up mid-list - the node only strips quotes if they wrap the entire string ("..." both ends). A quote in the middle is just treated as part of a tag. That's by design, not a bug.
    • "Too many tags" isn't a thing here - the node can't error on a long list; it'll just happily trim it. The only way to get surprising output is to misorder your tags and forget that the tail gets cut.

    For what it costs (nothing), it's a fine little utility to keep in your dynamic-prompt toolkit. Just don't expect it to think.

    Categorytag_limiter

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    limitINT400–1000

    Outputs (1)

    NameTypeDescription
    STRINGSTRING