Text & Writing Tools

Trim Text Online: Remove Leading and Trailing Spaces

Pasted text often comes with extra spaces at the start or the end. Paste it here, pick which side to trim, and get a cleaner result right away. Copy it with one click or download it as a .txt file.

0 characters

Options

Processing runs in this page using JavaScript. Do not paste confidential text on a computer you do not trust.

Why use this tool?

Why use this tool?

Extra spaces at the edges of a text are hard to see, but they can cause trouble in forms, spreadsheets, code and data files. Trimming by hand means clicking into the text and deleting spaces one by one. This tool does it in one step, and you choose which side gets trimmed.

How to use it

How to use it

  1. Step 1

    Add your text

    Type or paste your text into the Input text box, or press Load example.
  2. Step 2

    Choose the side

    Under Options, check the Side setting. The default is both.
  3. Step 3

    Check the result

    Read the trimmed text in the Result box.
  4. Step 4

    Copy or download

    Press Copy result to copy the text, or Download .txt to save it as a file.
  5. Step 5

    Start again if needed

    Press Clear to empty the tool and trim something new.

How to remove spaces from the start and end of text

Type or paste your text into the Input text box. Check the Side option under Options. The default is both, so the start and the end of the text are trimmed. Read the cleaned text in the Result box, then press Copy result or Download .txt.

Sample text you can copy and try

Paste this into the Input text box. It has extra spaces before and after the sentence: This text has extra spaces at both ends. You can also press Load example to fill the box with a ready-made sample.

What the Side option does

Side controls which side of the text gets trimmed. The default value is both, which means the start and the end. Use it when you only want to clean one edge of your text.

Trim text and download it as a .txt file

When the result looks right, press Download .txt to save it as a plain text file. This is useful when you have a lot of text to keep.

Features explained

Side option

Choose which side of the text to trim. The default is both.

Copy result

Copies the trimmed text to your clipboard. The button changes to Copied! when it works.

Download .txt

Saves the result as a plain text file you can open in any editor.

Load example

Fills the Input text box with sample text so you can see how the tool works first.

Clear

Resets the tool so you can start again with new text.

Works in your browser

Text is processed on the page with JavaScript. The tool's code has no step that sends your text to an API.

What can you use it for?

Cleaning pasted text

Remove stray spaces that come along when you copy text from a web page, PDF or document.

Preparing form input

Clean a name, email or code before you paste it into a form that does not accept extra spaces.

Spreadsheet and data work

Tidy text before you put it into a cell, a CSV file or a database field.

Code and configuration values

Remove extra spaces from a value or string before you use it in code or a settings file.

Editing and writing

Clean up the edges of a copied paragraph before you paste it into your own document.

Tool information

ProcessingIn your browser (client-side JavaScript)
InputPlain text typed or pasted into the Input text box
Main optionSide
Default sideboth
Output actionsCopy result, Download .txt
Download format.txt (plain text)
Extra buttonsLoad example, Clear

Benefits

  • Remove edge spaces in one step instead of deleting them by hand
  • Choose which side to trim
  • Copy the result or save it as a .txt file
  • Try the tool first with the built-in example

Limitations

  • It works with plain text typed or pasted into the box.
  • Download is available only as a .txt file.
  • Trimming deals with the edges of the text. Check the Result box if you also need spaces cleaned inside the text.
  • Copy anything important before you press Clear.

Your text stays in your browser

This tool processes your text on the page using JavaScript. The tool's code does not send your text to a server or API. Even so, avoid pasting passwords or other confidential text on a shared or untrusted computer.

Tips

  • Leave Side on both unless you only need to clean one edge.
  • Press Load example to see how the tool works before using your own text.
  • Check the Result box before you paste the text somewhere important.
  • Press Clear before starting a new job so old text does not get mixed in.

Frequently asked questions

How do I remove spaces from the start and end of text online?

Paste your text in the Input text box and keep Side on its default, both. The trimmed text appears in the Result box, ready to copy or download.

What does the Side option do?

It controls which side of the text is trimmed. The default is both, meaning the start and the end.

What is the default side?

The default is both.

How do I copy the trimmed text?

Press Copy result. The button changes to Copied! when the text is on your clipboard.

Can I download the trimmed text?

Yes. Press Download .txt to save the result as a plain text file.

Is my text uploaded to a server?

The tool processes text on the page with JavaScript, and its code does not send your text to an API. Still, do not paste confidential text on a computer you do not trust.

How do I clear the text and start again?

Press Clear to reset the tool, then add your new text.