ComfyUI Node

PromptTagsExtractorNode

Turn a finished prompt into upload-ready tags

By zeeoale·Created about a year ago·Updated 2 months ago· 9
PromptTagsExtractorNode
    • tags_csv
    • tags_space
    prompt
    top_k30
    keep_csv
    min_len4
    json_name
    force_name_tokenstrue
    name_tokens_max12

    PromptTagsExtractorNode (displayed as "PFN Prompt → Tags (Extractor)") turns a finished prompt into a clean, comma-separated tag list - the kind you'd paste into a gallery or dataset uploader. The generator writes long cinematic prose; this node chews it down into the flat keyword list Civitai-style galleries actually want.

    It exists because the pack's whole loop ends in "post the image somewhere." Manually boiling a 200-word cinematic sentence down to thirty tags is exactly the chore nobody wants to do fifty times. The node does the boring part: tokenize, strip filler, count, rank, output.

    How it works

    It lowercases and regex-cleans the prompt (drops {{tokens}}, punctuation, dashes), removes a hard-coded stopword list and a _PROMPT_GARBAGE set (all those "masterpiece, best quality, 4k, ultra detailed, absurdres" quality-padding words that mean nothing as tags), then counts remaining word frequencies with Counter and takes the top top_k. Two extras make it smarter than a plain frequency counter:

    • keep_csv is a whitelist - words you list there get a +3 score bonus, so a term that appears twice but matters more than the noise can still crack the top.
    • json_name extracts "identity tokens" from the world file name (e.g. PFN_Noir_Neon_Embersnoir, neon, embers) and, with force_name_tokens on, forces them to the front of the tag list - so the world's identity is always present in the tags even if those words never literally appear in the prompt.

    min_len (default 4) drops short junk words; name_tokens_max caps how many name tokens get forced in.

    The inputs that matter

    prompt and top_k (5–80) are the core. keep_csv and json_name are the two you'll actually tune - feed the same json_name you used in the generator and the output tags stay consistent with the world that made the image.

    Outputs and wiring

    • tags_csv (STRING) - comma-separated tags, for uploader forms.
    • tags_space (STRING) - the same tags space-separated, for prompt-style uses.

    Both are plain strings, so the obvious wiring is into a "show text"/save node or your uploader's tag field.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/zeeoale/PromptCreatorNode
    

    restart. Pure stdlib (re, collections.Counter, os) - no dependencies, no keys, no models. Probably the cheapest node in the pack to run.

    The honest take

    It's a simple frequency extractor with a world-name garnish, not a semantic tagger - it can't infer "cyberpunk" from a prompt that never says it, and the forced name tokens can look a little odd when the filename and image don't match up. But for its actual job - converting the pack's prose into uploader tags without thinking - it's fine, and the keep_csv whitelist gives you a lever when the raw frequency ranking misses what you care about. Where it genuinely shines is dataset captioning: run it over every generated caption, keep the same json_name, and your tag columns come out internally consistent.

    CategoryPFN/utils

    Inputs (7)

    NameTypeDefaultDescription
    promptSTRING
    top_kINT305–80
    keep_csvoptSTRING
    min_lenoptINT43–12
    json_nameoptSTRING
    force_name_tokensoptBOOLEANtrue
    name_tokens_maxoptINT123–24

    Outputs (2)

    NameTypeDescription
    tags_csvSTRING
    tags_spaceSTRING