ComfyUI Node

expandtabs

The most niche tab you'll ever fix

By StableLlama·Created about a year ago·Updated 4 days ago· 48
expandtabs
    • STRING
    string
    tabsize8

    This one's for a surprisingly specific pain: strings full of literal tab characters that need to become spaces. It's the most niche node in the string family, and that's fine - when you need it, you need it, because nothing else in the pack does this.

    What it does

    expandtabs is a wrapper over Python's str.expandtabs(tabsize). Every tab character in the input is replaced with enough spaces to reach the next tab stop - a multiple of tabsize, which defaults to 8. So "a\tb" at the default becomes "a b" (seven spaces), because "a" sits at position 1 and the next stop is 8.

    The inputs:

    • string - the text with tabs (required).
    • tabsize - spaces per tab stop, default 8, range 1–100 (optional).

    Output: one STRING.

    The thing to understand

    It doesn't insert a fixed number of spaces per tab. It aligns to tab stops. A tab after a long string produces fewer spaces, because it only pads up to the next multiple of tabsize. That's the correct behavior for columnar text - and it's the thing that makes the output look "wrong" if you expected 8 spaces every time. For aligned columns you want exactly this; for flat replacement you'd want something else.

    Why you'd reach for it

    Text pulled from config files, old-style docs, or tools that write tabs. You read a file in via the pack's path/load nodes, find it full of \t, and need clean spaces before you split or parse it. It's also a normalizing step before delimited parsing - tab-delimited data you want to turn into space-delimited.

    Honestly, most people never open this node. That's okay. It exists so that when your text is a minefield of tabs, the fix is one node, not a regex detour.

    Installing

    Part of Basic data handling by StableLlama. In ComfyUI Manager search "Basic data handling" → Install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart. Zero runtime dependencies - pure stdlib - so the install is trivial and can't conflict with anything.

    Where people get burned

    The tab-stop behavior, as above - don't assume flat padding. And remember it only affects actual tab characters; spaces, newlines, and everything else pass through untouched. If your text uses a mix, only the tabs move.

    CategoryBasic/STRING

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    tabsizeoptINT81–100

    Outputs (1)

    NameTypeDescription
    STRINGSTRING