Trim Whitespace
Strip leading and trailing whitespace from every line. Internal runs of spaces collapse to a single space. Cleans up text exported from PDFs, spreadsheets, and forms.
hello world
foo bar → hello world
foo bar
Strip leading and trailing whitespace from every line. Internal runs of spaces collapse to a single space. Cleans up text exported from PDFs, spreadsheets, and forms.
hello world
foo bar → hello world
foo bar
Strips leading and trailing whitespace (spaces, tabs) from every line, and collapses runs of internal whitespace into single spaces. The most common normalisation step before further processing.
Especially useful for text copied from PDFs (which often arrives with stray double-spaces), spreadsheet exports, or form-pasted user input.
User-entered emails and names often arrive with leading/trailing spaces from copy-paste. Trim before storing or comparing.
PDF copy-paste produces erratic spacing. Trim and collapse to get a clean string.
Before removing duplicates, trim — otherwise "hello" and "hello " stay distinct.
Copy a column out of Excel, trim, paste back — fixes alignment issues from inconsistent spacing.
Trimming queries before sending them to a search API avoids "no results" caused by trailing whitespace.
Yes. Tabs, spaces, and any other Unicode whitespace are all stripped.
Yes — runs of two or more whitespace characters between words collapse to a single space. If you need to preserve double-spaces, do the leading/trailing trim manually.
No — empty lines stay as empty lines. Use Remove Blank Lines for that.
Yes — JavaScript's \s regex matches non-breaking spaces, so they're collapsed too. If you need to preserve , use a custom regex.