ComfyUI Node

Shrug Text Cleanup

The 30-second fix for ugly VLM output

By fblissjr·Created about a year ago·Updated 4 months ago· 25
Shrug Text Cleanup
    • text
    text
    levelstandard

    LLMs are chatty, and their chatty-ness lands in your graph as strings with leading/trailing whitespace, doubled blank lines, stray em-dashes, and the occasional smart quote from a model that was trained on the entire internet. If you're wiring ShrugVLM output into a prompt encoder, a filename builder, or anything that compares strings, that junk quietly breaks things. Shrug Text Cleanup is the pack's tiny answer: one string in, one string out, with a level knob that decides how aggressive the cleanup is.

    It's the most boring node in the pack and possibly the most dependable. It doesn't talk to the server, has no dependencies to worry about, and it always does what it says.

    How it works

    There are four levels, and the differences matter:

    • none - the string passes through untouched.
    • basic - strips leading/trailing whitespace.
    • standard (default) - basic plus Unicode NFC normalization (so composed and decomposed characters that look identical actually compare equal), trailing-whitespace removal per line, and collapsing runs of blank lines down to one. This is the setting that kills the "Here is your caption:\n\n\n\n" problem.
    • strict - everything above, then strips to ASCII only, dropping any remaining non-ASCII characters.

    The mechanism is a single pure function in the pack's source - no magic, no ML, just unicodedata and string ops. If you've ever had two strings that look the same but fail an equality check, the NFC step in standard is probably the fix you were missing.

    Inputs and outputs

    • text (required) - the string to clean.
    • level (required) - the combo above, default standard.

    One output: text - the cleaned string. That's the whole node.

    Where to slot it: between ShrugVLM/Shrug VLM Batch and whatever consumes the text. If your downstream uses the text as a filename or a comparison key, strict (ASCII-only) is worth considering - non-ASCII characters are a classic source of "why won't this path work" bugs on Windows and in some toolchains. If it's going into a prompt box, standard is usually right; you want to keep the meaning but kill the formatting noise.

    How to install

    Standard pack install. ComfyUI Manager → search Shrug-Prompter → Install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fblissjr/shrug-prompter
    

    Dependencies are already present in any modern ComfyUI (httpx, orjson, pillow, torch, numpy), and this node adds nothing beyond them. It's a pure utility - no ShrugConnection, no server, works in any graph.

    Common issues

    • "It didn't change anything." If you're on none, correct - that's the point. And strict on text that's already ASCII is a no-op. Try standard and look at the whitespace.
    • Text came back more broken. If you set strict on text with non-ASCII content, characters get dropped, not transliterated - "café" becomes "caf". That's by design; use standard if you want the characters kept.
    • Node not in the list. Old ComfyUI without the V3 extension API won't register the pack. Update ComfyUI first.
    Categoryshrug

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    levelCOMBOstandard4 options: none, basic, standard, strict

    Outputs (1)

    NameTypeDescription
    textSTRING