Skip to content

Remove Whitespace

What to remove
Cleaned text —
Characters removed
—
Characters before
—
Characters after
—
Whitespace characters found
—
Tabs found
—

Paste the text and choose what to remove: runs of extra spaces, only the ends of each line, line breaks, or all whitespace. For example, ' Hello world ' becomes 'Hello world', which takes out 6 of its 17 characters. Tabs and non-breaking spaces are caught as well.

About this tool

Text copied from PDFs, spreadsheets, emails and web pages often carries double spaces, stray tabs, trailing blanks and hard line breaks that break a form field, a CSV import or a search match. This tool cleans that up in four ways: collapse runs of spaces to one, trim only the start and end of each line, join everything into one line, or delete every whitespace character for codes, IBANs and phone numbers. It reports the characters before and after, how many were removed, and how many tabs and whitespace characters were in the original. It treats non-breaking and ideographic spaces as whitespace, which is usually what you want but will also remove deliberate non-breaking spaces in typeset text.

How to use it

  1. Add the text

    Paste into the box or open a plain .txt or .csv file from your device.

  2. Pick what to remove

    Choose extra spaces, leading and trailing, line breaks or all whitespace.

  3. Decide on blank lines

    In the first two modes, tick or untick Remove blank lines.

  4. Copy the cleaned text

    The result and the character counts update as you type; copy the cleaned text out.

Examples

Double spaces around two words

Your text
Hello world
What to remove
Extra spaces
Remove blank lines
Yes

Result Cleaned text: Hello world
Characters removed: 6
Characters before: 17
Characters after: 11
Whitespace characters found: 7
Tabs found: 0

  1. Collapsed runs of spaces and tabs to one space and trimmed each line.
  2. Dropped lines that were empty after trimming.
  3. Characters: 17 before − 11 after = 6 removed.

Two leading spaces, three between the words and two trailing ones shrink to the single space between Hello and world.

Strip a code with spaces and a tab

Your text
a b c d
What to remove
All whitespace

Result Cleaned text: abcd
Characters removed: 3
Characters before: 7
Characters after: 4
Whitespace characters found: 3
Tabs found: 1

  1. Removed every whitespace character.
  2. Characters: 7 before − 4 after = 3 removed.

A space, a tab and a line break are all removed, leaving the four letters joined.

Join wrapped lines

Your text
one two three
What to remove
Line breaks

Result Cleaned text: one two three
Characters removed: 2
Characters before: 15
Characters after: 13
Whitespace characters found: 4
Tabs found: 0

  1. Joined all lines into one line with single spaces.
  2. Characters: 15 before − 13 after = 2 removed.

Text copied from a PDF with hard line breaks becomes a single line with one space between words.

How it is calculated

removed = characters before − characters after

whitespace
spaces, tabs, line breaks, non-breaking spaces and other Unicode space characters
characters
Unicode code points in the text, including invisible ones

Extra spaces mode replaces any run of spaces or tabs inside a line with a single space and trims both ends of every line. Leading and trailing mode trims only the ends. Line breaks mode turns every run of whitespace, including newlines, into one space. All whitespace mode deletes every whitespace character. Blank lines can be dropped in the first two modes.

When not to use it

  • Python, YAML and Makefiles rely on indentation, so trimming lines will break that code.
  • Poetry or tables aligned with spaces lose their layout once runs of spaces are collapsed.

Common mistakes

  • Choosing All whitespace for prose, which glues every word together.
  • Joining lines in a list where each line is a separate record.

Frequently asked questions

Does it remove tabs and non-breaking spaces?

Yes. Tabs, non-breaking spaces (U+00A0), thin and em spaces and the ideographic space used in Chinese and Japanese text all count as whitespace. A note appears when special-width spaces were found.

What is the difference between Extra spaces and Leading and trailing?

Extra spaces also shrinks gaps inside a line, so 'a b' becomes 'a b'. Leading and trailing leaves inner gaps alone and only removes spaces at the start and end of each line.

How do I turn a paragraph copied from a PDF into one line?

Choose Line breaks. Every newline and run of spaces becomes a single space, so wrapped lines from a PDF or email join into one continuous line.

Why is the characters removed count larger than I expected?

Line breaks and tabs are invisible but count as characters. A Windows line break is two characters, a carriage return and a newline, so text with many lines can lose more characters than the visible spaces suggest.

Can I clean a phone number or IBAN with it?

Yes. All whitespace mode removes every space, so 'GB29 NWBK 6016 1331 9268 19' becomes one unbroken string ready to paste into a banking or form field.

Is my text uploaded?

No. The cleaning runs in your browser, and a file you open is read locally rather than sent to a server.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 19). Remove Whitespace. Tools Directory. Retrieved October 26, 2026, from https://tools.milunir.com/text-tools/cleanup-sorting-and-lists/remove-whitespace/

MLA

Tools Directory Editorial Team. “Remove Whitespace.” Tools Directory, 19 Oct. 2026, https://tools.milunir.com/text-tools/cleanup-sorting-and-lists/remove-whitespace/. Accessed 26 Oct. 2026.

Chicago

Tools Directory Editorial Team. “Remove Whitespace.” Tools Directory. Last modified October 19, 2026. Accessed October 26, 2026. https://tools.milunir.com/text-tools/cleanup-sorting-and-lists/remove-whitespace/.

Link<a href="https://tools.milunir.com/text-tools/cleanup-sorting-and-lists/remove-whitespace/">Remove Whitespace – Tools Directory</a>