Skip to main content

Trim Leading & Trailing Spaces

Remove whitespace from the start and end of every line, without touching spaces inside the text.

Reviewed for accuracy by the Math Ora X team Last updated

About this tool

Remove whitespace from the start and end of every line, without touching spaces inside the text.

Example

Input: hello world

Output: hello world

How to use

Paste or type your text into the box above, then read or copy the result. Everything runs privately in your browser, your text is never uploaded to a server.

How to use this tool

  1. Paste or type your text into the input box.
  2. Choose the option to trim spaces from each line.
  3. Review the cleaned text in the output area.
  4. Copy the result and use it in your file, message, or code.

Step by step, what happens

  1. The tool reads your text line by line, not as one single block.
  2. For each line, it removes whitespace only from the start and the end.
  3. It leaves spaces, tabs, and other characters inside the line unchanged.
  4. The cleaned lines are then shown back to you as the output.

Worked example

If a pasted note has extra spaces around each line, this tool cleans them without changing the words inside the lines.

Input: apple pie banana split cherry tart

  1. The first line has spaces before and after the words, so those are removed.
  2. The second line has tabs around the text, so those are removed too.
  3. The third line loses only the spaces at the start, while the words stay the same.

Output: apple pie banana split cherry tart

Tips and common mistakes

  • This tool trims each line separately, so it is useful for pasted lists and multi line text.
  • It does not remove spaces between words, so internal formatting stays intact.
  • If a line seems unchanged, check whether the extra spacing is inside the line rather than at the edges.
  • Tabs count as whitespace, so they are removed from the start and end of a line too.

Frequently asked questions

What is trimmed?

Spaces and tabs at the beginning and end of each line are removed.

Are inner spaces kept?

Yes, only the edges of each line are trimmed.

Does it remove blank lines?

No, empty lines remain; use Remove Empty Lines for that.

More Text Tools Tools

Explore related calculators in this category

You Might Also Like

Popular tools from other categories

Can't Find the Right Calculator?

Try our AI Math Solver, type any problem in plain English and get instant step-by-step solutions.

Try AI Solver

Browse All Categories

Home Text Tools Current Tool
Facebook Twitter WhatsApp