Nodes/Wildcard Pipeline/WP Prompt Cleaner
ComfyUI Node

WP Prompt Cleaner

A Reasonable Lint Pass for Prompts That Look Like a Cat Walked on the Keyboard

By DumiFlex·Created 5 months ago·Updated 19 days ago· 9
WP Prompt Cleaner
  • wp_cleaner
  • prompt
prompt

The wildcard approach breeds messy prompts. It's not a bug - it's what happens when you assemble a string from a dozen modules, each contributing fragments, weights, and punctuation, and then a combine interpolation leaves a trail of double spaces and stray commas. WP Prompt Cleaner is the lint pass for that. You feed it any prompt string - most naturally the output of WP Prompt Assembler - and it runs a configurable set of text rules over it before the result goes to CLIP. No context needed, no variables involved, just string in, string out.

How it works

Two required inputs: prompt (a STRING, multiline) and a wp_cleaner widget that holds the configuration JSON. The engine applies rules in a fixed order, and the config picks which rules run and how aggressively.

There are five rules in the registry:

  • whitespace - collapse double spaces, clean up comma gaps and stray spaces before punctuation.
  • punctuation - normalize punctuation runs.
  • dedupe_exact - remove exact duplicate words or tags.
  • fuzzy_dedupe - catch near-duplicates (the case where one wildcard says "masterpiece" and another says "masterpiece, best quality").
  • blocklist - drop entries from a user-supplied list (say, terms that keep slipping through your constraint logic).

The config also has an intensity preset - gentle, balanced, or aggressive - which maps to a default rule set: gentle runs only whitespace, balanced adds punctuation and exact dedupe, aggressive throws in fuzzy dedupe. You can override individual rules on top of the preset (rules_override), and the blocklist auto-enables whenever it has entries unless you explicitly turn it off. Everything runs in registry order regardless of preset, so output stays deterministic.

There's a mode in the config too (tags vs prose), and it matters: the same dedupe that's harmless on a comma-separated booru-tag prompt would mangle natural English. Match the mode to what your downstream model actually wants - tag lists for SDXL-lineage models, prose for the LLM-encoded 2026-generation checkpoints.

The output is a cleaned prompt STRING, plus a per-rule report (word/char counts) the widget displays after execution - so you can see exactly what each rule changed rather than trusting it blindly. If you want the report visible at a glance, wire WP Debug into your context chain; the cleaner itself is a pure string transform.

Where it fits

The honest take: for a hand-written prompt, you don't need this. But for generated prompts - wildcard pipelines, LLM outputs, concatenated tag builders - it earns its place fast, and it's cheap insurance before CLIP encoding. The blocklist alone is worth it if you're assembling prompts from a large tag pool where a banned term occasionally sneaks through a constraint.

Install

Part of the pack, so it's the same one-time setup: ComfyUI Manager → search Wildcard Pipeline → install, or the git clone + pip install -e . + pnpm build route. Needs ComfyUI ≥ 0.3.36; zero model downloads.

The trap is over-eagerness. "Aggressive" mode with fuzzy dedupe is genuinely destructive on a long varied prompt - it can collapse two different but similar-sounding tags you actually wanted both of. Start at balanced, read the per-rule report before you commit to a pipeline, and treat aggressive as a deliberate aesthetic choice, not a default.

Categorywildcard-pipeline

Inputs (2)

NameTypeDefaultDescription
promptSTRINGPrompt text to clean up. Wire from an upstream WP Prompt Assembler (or any other string source) and the configured rules — punctuation, weights, duplicates, blocklist — apply on top.
wp_cleanerWP_CLEANER{}

Outputs (1)

NameTypeDescription
promptSTRING