Removing Leading And Trailing Spaces deletes the spaces at the start and end of your text or of each line. Paste your text, click the button and copy the result. It is free and runs in your browser.
The sky is clear; the stars are twinkling.
The sky is clear; the stars are twinkling.
Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
This tool removes the spaces at the start and at the end of your text. These are called leading and trailing spaces. They are easy to miss, but they cause trouble in forms, spreadsheets, code and file names.
You can trim the whole text at once, or trim each line separately, which is the default. Spaces between words are never touched, so only the edges are cleaned. Tabs and non-breaking spaces can be removed too, and you can also delete empty lines at the start and end.
Use it to clean pasted text, lists, email addresses, CSV data and anything copied from a web page or a PDF.
Unless an option is named, each line is trimmed, tabs and non-breaking spaces count as spaces and empty lines are kept.
| Setting | Before | After |
|---|---|---|
| Text with spaces around it | The sky is clear; the stars are twinkling. | The sky is clear; the stars are twinkling. |
| Each line, on | one two three | one two three |
| Each line, off (whole text only) | one two three | one two three |
| Spaces inside are kept | a b | a b |
| Tabs, on | indented | indented |
| Tabs, off (only spaces) | x | x |
| Empty lines at the end, kept | a b | a b |
| Empty lines at the end, removed | a b | a b |
Cleaning pasted text, lists, email addresses and CSV data, and fixing text copied from web pages, PDFs and spreadsheets before you use it.
Indentation counts as leading spaces, so code or lists with indents lose them when each line is trimmed. Untick Trim each line separately to keep the indent of the lines in the middle. The result replaces your text, so use Undo if you need the original.
To shrink spaces between words, try Remove Extra Spaces. To delete every space, try Remove Spaces. To clean tabs, try Remove Tabs From Text.
It removes the spaces at the start and at the end of your text, or of each line, and leaves the spaces between words as they are.
Leading spaces come before the first character of a text or line. Trailing spaces come after the last character. They are hard to see but can break forms, searches and data.
Paste or type your text, then click Trim Spaces. Copy the result with the Copy button.
No. Only the spaces at the edges are removed. To change spaces between words, use Remove Extra Spaces.
With Trim each line separately ticked, every line is cleaned at both ends. Unticked, only the very start and the very end of the whole text are cleaned, and the lines in between keep their spaces.
Yes, by default, because they look like spaces but are different characters. Untick that option to remove normal spaces only.
Yes. Tick Also remove empty lines at the start and end. Empty lines in the middle of the text are not touched.
The tool shows a message and leaves your text as it is.
Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.
Last updated: 14 November 2026