String Lstrip
Shave leading whitespace only, and leave the rest alone
- string
String Lstrip is the one-sided cleaner: it strips whitespace from the front of a string and leaves the end completely alone. It's a niche tool, but when you need exactly that, nothing else in this pack does it.
What it is
It runs Python's s.lstrip() - the "left strip." Leading whitespace (spaces, tabs, newlines) gets removed; trailing whitespace and everything in the middle stays untouched. " hello world\n" becomes "hello world\n". Note that trailing newline survives - which is precisely the point when you're cleaning the start but need the end intact for something else.
When would you want that asymmetry? Fixed-format strings where the tail matters: a filename that must keep its extension structure, a line of text whose ending you're about to check with String EndsWith, or data where trailing whitespace is actually significant. If you just want everything clean on both ends, String Strip is the node you really want - this one is for the cases where only the front is the problem.
The inputs and outputs
s(STRING) - the text to clean.string(STRING) - the same text with leading whitespace removed.
One in, one out. If you need the mirror image, String Rstrip in the same pack handles the trailing side.
How to install it
Part of the string-util pack, a dependency-free repo like every node in it:
cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-string-util
or install "ComfyUI-string-util" via ComfyUI Manager and restart. It's under the string-util category.
Common issues
The only realistic confusion is picking the wrong sibling. If you run this and your output still has whitespace at the end, that's not a bug - lstrip only touches the front by design. Grab String Strip for the both-ends version. And like every trim node, it won't touch interior whitespace: "a b" stays "a b". For genuinely malformed text with stray spaces throughout, you want String Replace instead.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| s | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |