Trim Whitespace
Remove leading and trailing whitespace from text or each line.
Trim spaces and tabs from the start and end of each line, from the whole text only, or from just the start or the end of lines. You can also remove empty lines. It's useful for lists copied from spreadsheets or web pages, where invisible trailing spaces cause mismatches in lookups, comparisons and imports.
Common use cases
- Clean a list before importing it into a spreadsheet or database
- Remove indentation from pasted code or text
- Fix trailing spaces that break VLOOKUP or matching
How to use
- Paste the text.
- Choose what to trim and whether to remove empty lines.
- Copy the result.
FAQ
Why do trailing spaces matter?
To a computer, "apple" and "apple " are different, so invisible spaces make lookups, de-duplication and logins fail.
Is there a spreadsheet formula for this?
TRIM() in Excel and Google Sheets removes spaces at both ends and turns runs of spaces into one.
Related tools
- Remove WhitespaceStrip all whitespace characters including spaces, tabs, and newlines from text.
- Remove Duplicate SpacesReplace multiple consecutive spaces with single spaces throughout text.
- Clipboard CleanerClean and sanitize pasted text by removing formatting.
- Remove PunctuationRemove all punctuation marks from text while keeping letters and numbers.
- Sort Lines AlphabeticallySort all lines of text in alphabetical or reverse alphabetical order.
- Reverse LinesReverse the order of lines in text from last to first.