Nodes/ComfyUI Ino Nodes/Ino String Trim
ComfyUI Node

Ino String Trim

Strip the accidental whitespace from anything pasted

By nobandegani·Created about a year ago·Updated 2 months ago· 6
Ino String Trim
    • string
    input_string
    mode

    Paste a prompt from anywhere and it arrives with stray newlines and spaces at the edges. Usually harmless. Sometimes not - a filename with a trailing space is a classic source of "why can't my script find this file" debugging, and extra whitespace can quietly break string comparisons that are supposed to match. Ino String Trim removes leading and/or trailing whitespace, and lets you pick which side. It's a tiny cleanup node that prevents a disproportionate amount of pain.

    It's part of the ComfyUI Ino Nodes pack (nobandegani/ComfyUI-InoNodes).

    Inputs and output

    • input_string - the text to clean. Multiline, because pasted text is where the problem lives.
    • mode - a dropdown with three options: both, left, or right. both (the default behavior) strips from both ends; left and right only strip their side.

    One string output with the cleaned text.

    The mechanism is Python's strip / lstrip / rstrip, which means it removes whitespace - spaces, tabs, newlines - but nothing else. A character you typed deliberately at the edge is safe. If you need to remove a specific character class instead (say, all the - and _ from a string), that's the pack's Ino String Strip Simple, not this node.

    Where it fits

    The workhorse pattern is pipeline hygiene: run scraped or pasted text through Trim before it hits a comparison node, a filename builder, or Ino Save Text. It costs nothing, and it eliminates a whole class of "these two strings look identical but aren't" bugs. If you've ever built a workflow where a switch never matched because of a trailing newline, you already know why this node exists.

    One honest note: most of the time you won't see it doing anything, because you can't see invisible whitespace in the node UI. That's fine - it's an insurance node. Wire it in front of anything case- or string-sensitive and move on.

    Install

    # ComfyUI Manager: search "ComfyUI Ino Nodes", install, restart
    # or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/nobandegani/ComfyUI-InoNodes.git
    cd ComfyUI-InoNodes
    pip install -r requirements.txt
    

    Restart ComfyUI after. No models, no services - requirements.txt installs the pack's core dependency, inopyutils. The pack runs on ComfyUI's V3 schema, so keep ComfyUI reasonably current (v0.18.1+); and ignore the README's cd comfyui_ino_nodes typo - the cloned folder is ComfyUI-InoNodes.

    The one thing to remember is what it does not do: both still only touches the edges, so whitespace in the middle of the string stays. If your data has interior junk, that's a replace or strip-simple job. For edge whitespace - which is the common case - this is the right tool, and it's all of two fields.

    CategoryInoStringHelper

    Inputs (2)

    NameTypeDefaultDescription
    input_stringSTRING
    modeCOMBO3 options: both, left, right

    Outputs (1)

    NameTypeDescription
    stringSTRING