Nodes/ComfyUI 1hewNodes/String Filter
ComfyUI Node

String Filter

Clean the junk out of your prompt text

By 1hew·Created about a year ago·Updated 7 days ago· 33
String Filter
    • string
    text
    filter_empty_linefalse
    filter_commentfalse
    input

    Prompt blocks accumulate junk. Comments left from experimentation, blank lines, notes-to-self written right in the middle of a positive prompt. String Filter is the text scrubber: it strips # comments and """/''' comment blocks, optionally removes empty lines, and substitutes a variable into placeholders - all before the string heads to your text encoder. It's the node you put between "the prompt I'm drafting" and "the prompt I actually run."

    How it works

    The input text is processed line by line. With filter_comment on, everything after a # on a line is removed, #-prefixed lines are dropped entirely, and multi-line blocks wrapped in triple quotes get excised even if they span several lines. With filter_empty_line on, blank lines vanish. Both off (the default) means the text passes through as-is - it's opt-in cleaning, not silent rewriting.

    Then there's the substitution: {input} - and also {n}, for compatibility with the pack's other text nodes - gets replaced with the value of the input field. This is how you inject a variable into a template without string surgery elsewhere: write a {input} on the beach, feed input = "sunset", and the prompt becomes a sunset on the beach. It's a small templating feature that keeps template blocks reusable.

    One input worth knowing: the field is text (multiline) plus input (single-line). Don't mix them up - text is what gets cleaned, input is what gets substituted into the {input} placeholder.

    The inputs that matter

    • text (STRING, multiline) - the text to clean.
    • input (STRING) - value for {input} / {n} substitution.
    • filter_comment (BOOLEAN, default off) - strip comments.
    • filter_empty_line (BOOLEAN, default off) - drop blank lines.

    One output: string (STRING), the cleaned result.

    Installing it

    ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/1hew/ComfyUI-1hewNodes
    

    Restart ComfyUI. Pure string processing - no models. The pack pulls heavyweight requirements regardless, and it needs a current ComfyUI (comfy_api.latest API).

    Common issues

    The filters are off by default, which is the single most common point of confusion: people assume a "filter" node cleans out of the box, and it doesn't until you flip the switches. Also note the comment char is # specifically - if your prompt text uses a different marker for notes, it won't be stripped. And {input} is a literal placeholder match: a prompt that happens to contain {input} text with an empty substitution value leaves the placeholder removed but not replaced with anything, so check your templates if a keyword seems to be vanishing from output.

    Category1hewNodes/text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    filter_empty_lineBOOLEANfalse
    filter_commentBOOLEANfalse
    inputSTRING

    Outputs (1)

    NameTypeDescription
    stringSTRING