Trim leading and trailing spaces
Removes spaces and tabs at the very start and end of each line.
Example
- Options used
- Default options
apple·· ⇥ banana cherry···
apple banana cherry
Symbols in examples: ⇥ tab · · trailing space · ⍽ NBSP · □ full-width space · ◌ zero-width character
Open this operation in the toolWhat it does
Removes the whitespace at the very beginning and end of every line. Besides ordinary spaces and tabs, it also treats the no-break space (NBSP, U+00A0) that often tags along from web pages and Word documents, and the full-width space (U+3000) used in Chinese, Japanese and Korean documents, as whitespace. Spaces in the middle of a line are left untouched.
Options
- Both ends: the default. Cleans both ends of the line.
- Start only: removes indentation and leaves the end of the line as is.
- End only: keeps indentation and removes only the invisible trailing spaces. Useful when working with code or Markdown.
When to use it
When you copy Excel cells, survey responses or web tables, values often come with spaces attached before or after them. They look identical to a person, but John and John are different strings, so deduplication and comparisons fail. That is why most recipes put this step near the top.
Use Collapse repeated spaces and tabs for runs of spaces inside a line, and Remove blank lines for lines that contain only whitespace.