Nodes/comfyui-flower-tools/🌸Flower Remove Commented Text
ComfyUI Node

🌸Flower Remove Commented Text

Strip // and /* */ comments out of a prompt without breaking the text

By weichenglin0215·Created 8 months ago·Updated 2 months ago· 0
🌸Flower Remove Commented Text
    • text
    ◄text►
    ◄starting_line_comment//►
    ◄enclosed_comment_start/*►
    ◄enclosed_comment_end*/►

    Writing notes inside your prompt files is a great habit - until the note ends up in the actual prompt and the model starts drawing "// fix this later". Flower Remove Commented Text is the cleanup pass: feed it text with comments in it, get the same text back with the comments gone. It's one of the simplest nodes in the comfyui-flower-tools pack, and it does exactly one thing, which is why it's reliable.

    What it strips

    Two comment styles, both configurable:

    • Line comments - anything after the marker (default //) up to the end of that line.
    • Block comments - everything between the start and end markers (default /* and */), across multiple lines if needed.

    The defaults match code-comment conventions, but the fields are plain strings, so you can point them at anything. Want to strip <note> … </note> blocks from a screenplay instead? Set enclosed_comment_start to <note> and enclosed_comment_end to </note>. Want to kill # hashtags as line comments? Set starting_line_comment to #. That flexibility is the whole reason it beats a hand-rolled find/replace: it understands nesting of the two styles, not just literal substitution.

    The one input that matters

    The only input you'll touch most days is text (multiline, the thing to clean). The three comment-marker fields have sane defaults and you'll leave them alone unless you're using a different convention. Output is a single text STRING - wire it into a CLIP Text Encode, or into another Flower node further down a prompt-building chain.

    Where it really earns its keep: the companion Flower Multiline Prompt Selector already has a "strip comments on output" toggle built in, but this node works on any text source - hand-typed prompts, LLM output, files loaded from disk. If your wildcard files carry /* explanations */ for future-you, run this before encoding and the model never sees them.

    Install and deps

    Same story as every node in the pack - it's all one clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/weichenglin0215/comfyui-flower-tools.git
    

    Restart, and look under the flower-tools category. ComfyUI Manager users can search ComfyUI Flower Tools instead. No models, no extra dependencies beyond the pack's single opencc requirement (which only the TCSC converter actually uses).

    Where people get burned

    Two edge cases, both worth knowing before you blame the node:

    • Empty markers are "off". If you set a marker to an empty string, that comment style is skipped entirely - handy, but surprising if you accidentally clear a field.
    • Unclosed blocks eat the rest. If your text opens a /* and never closes it, everything after the opener is discarded. The node can't know you meant it to stay. When output comes back suspiciously short, look for an unclosed block first.

    Also note it returns the text without a leading comment-trim on every line - it's not a formatter, it's a stripper. If you want sentences reflowed or lines cleaned, that's what the sibling Flower Split Sentences node is for.

    Categoryflower-tools

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING—
    starting_line_commentSTRING//—
    enclosed_comment_startSTRING/*—
    enclosed_comment_endSTRING*/—

    Outputs (1)

    NameTypeDescription
    textSTRING—