Nodes/Chaser's Custom Nodes/Prompt Formatter
ComfyUI Node

Prompt Formatter

Turn a messy multiline prompt into tidy comma-joined tags

By chaserhkj·Created about a year ago·Updated 11 months ago· 0
Prompt Formatter
    • STRING
    • TAGS
    prompt
    prefix

    Prompt Formatter is the cleanup crew for tag-based prompting. You feed it a multiline prompt - notes included - and it returns the same content as a single comma-joined string, with comment lines stripped and bracket groups preserved. If you prompt an Illustrious/Pony-lineage model with danbooru-style tags, this is the node that keeps your prompt block readable and your actual output clean.

    Two inputs: prompt (multiline, required) and prefix (optional). Two outputs: STRING, the joined result, and TAGS, the same content as a structured list.

    What it actually does, in order:

    • Splits your input into lines, strips whitespace, and drops any line starting with # - so you can leave notes in your prompt block without them leaking into the generation.
    • Ensures each line ends with a comma, then splits the whole thing on commas into individual tags.
    • Handles bracket groups intelligently: (detailed face:1.2) or even (foo, bar:1.2) stays intact as one unit instead of being shredded at the inner comma. That's the part that beats a naive "join with commas" node.
    • Joins everything with ", " and prepends the prefix if you gave one.

    Why you'd reach for it. Two patterns. First, normalization: keep your prompt in ComfyUI as readable multi-line blocks (with # annotations for what each block does), and let this node flatten it into the comma-tag form the model actually wants. Second, prefix management: wire a shared quality block into prefix - masterpiece, best quality, very aesthetic, high resolution and friends - so every prompt you run inherits the quality tags without you pasting them a hundred times. This is exactly the workflow that common.j2 macros in the same pack formalize.

    Where the outputs go. STRING feeds CLIP text encode (positive or negative) or any text consumer. TAGS is the raw list version of the same content - mostly useful if something downstream expects a tag collection, or for eyeballing what the formatter actually produced. Most of the time you'll use STRING and ignore TAGS.

    Gotchas:

    • This node reorders nothing - it joins in the order given. The output is as long as your input; it's a formatter, not a prompt-shortener.
    • Lines starting with # vanish. If you genuinely want # in a prompt, this node is working against you.
    • It's punctuation-aware, not semicolon-aware. BREAK (the SDXL line-separator keyword) just rides along as a tag; that's expected behavior, not a bug.
    • The prefix is prepended, so if it already ends with a comma you'll get a double comma. Keep prefixes clean.

    Install is the pack standard: ComfyUI Manager, search "Chaser's Custom Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chaserhkj/ComfyUI-Chaser-nodes
    

    then restart. No models to download; the pack's dependencies (jinja2, pyyaml, requests, sexpdata, av) install automatically. And keep the README's warning in mind - these are personal ad-hoc nodes from chaserhkj, "use them at your own risk" - though for a string formatter, the risk ceiling is low.

    CategoryChaser Custom Nodes

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRING
    prefixoptSTRING

    Outputs (2)

    NameTypeDescription
    STRINGSTRING
    TAGSTAGS