Nodes/ComfyUI-PromptComment/Prompt Comment (Strip)
ComfyUI Node

Prompt Comment (Strip)

Keep comments in your prompt without feeding them to the model

By smartvain·Created 7 months ago·Updated 7 months ago· 0
Prompt Comment (Strip)
    • text
    text
    comment_style
    custom_marker#
    remove_empty_linestrue
    trim_whitespacetrue

    ComfyUI's prompt box has no comment syntax. Type # quality tags next to your tags and the CLIP encoder treats the # as just another token - congratulations, you've added a word the model actually sees and that changes nothing. Prompt Comment (Strip) fixes that: you annotate your prompt with # or // markers, and the node deletes everything after the marker before the text ever reaches an encoder.

    Why bother? If you're on the SDXL lineage - Illustrious, NoobAI, Pony - you're still living in comma-separated booru-tag land, and those prompts get long. When a prompt is 40 tags long it stops being readable three days later, and it's worse when you're sharing a workflow: the "workflow included" culture means people drag your JSON into their graph and should be able to tell what each block of tags does. This node is the difference between "1girl, solo, blue hair" and "1girl, solo, # character / blue hair, # appearance". The comment stays in your workflow file, and only the clean prompt hits the sampler.

    How it works

    The whole mechanism is a loop over lines, and it's refreshingly dumb. It splits your text on newlines, finds the first occurrence of your marker with a plain string search, and cuts everything from that point to the end of the line. Then it strips whitespace, drops empty lines if you asked, and rejoins. That's the entire node - one Python file, no dependencies, no model downloads.

    The README shows the wiring: [String Literal] → [Prompt Comment] → [CLIP Text Encode]. Any text source works, not just String Literal - feed it from a Load Text file or a group of nodes. The output text is a STRING, so it plugs into CLIP Text Encode, or any other text-input node you like.

    The inputs that matter

    Only three are worth touching:

    • comment_style - pick #, //, --, or Custom. This is the marker that gets stripped.
    • custom_marker - only used when comment_style is Custom; set your own marker here. If you leave it empty, the node returns your text unchanged.
    • text - the prompt itself, and it's multiline, so paste freely.

    remove_empty_lines (default on) and trim_whitespace (default on) handle cleanup. Both defaults are what you want, so most people never touch them.

    Where people get burned

    The string search is naive - there's no escaping and no awareness of quoted text, and the source comments admit as much. A # inside a hex color like blue eyes #4a90d9 will eat the rest of the line. If your prompt contains a URL, the // in https:// is a marker and everything after it dies. It's a trade-off for a utility this small, but it's worth knowing before a "clean prompt" mysteriously sheds a third of its tags.

    Install

    Two options, both trivial. If you have ComfyUI Manager (and since it became core, you mostly do), search "PromptComment" in the Manager's custom-nodes tab and hit install. Or clone it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/smartvain/ComfyUI-PromptComment
    

    Then restart ComfyUI. There is no requirements.txt, no pip step, no models to fetch - the whole pack is one file of pure-Python string handling. It's MIT licensed and, because it's that small, you can read every line of it before you run it, which is more than you can say for most of the node ecosystem. One quirk: the README's clone URL literally says YOUR_USERNAME as a placeholder; ignore that and use the smartvain URL above.

    If the node doesn't show up after installing, restart ComfyUI once - the text/utils category is where it lives in the node search. If it silently does nothing, check that custom_marker is actually filled in when comment_style is Custom, and remember an empty custom marker is a no-op by design. This is a small, opinionated utility: it does one thing, does it in ~40 lines, and it's been fine for me as a permanent resident between my prompt editor and the encoder.

    Categorytext/utils

    Inputs (5)

    NameTypeDefaultDescription
    textSTRING
    comment_styleCOMBO4 options: #, //, --, Custom
    custom_markerSTRING#
    remove_empty_linesBOOLEANtrue
    trim_whitespaceBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    textSTRING