Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Whitespace Remover

Trim lines, collapse extra spaces, convert tabs and fix line endings.

Text No upload Works offline Free, no sign-up

Or drop a text file on the box. Nothing leaves your device.

Remove

Next steps

About the Whitespace Remover

Text copied from PDFs, web pages, spreadsheets and emails is often full of invisible problems: double spaces between words, spaces at the ends of lines, stray tabs, empty lines, no-break spaces that look normal but break searches and comparisons, and Windows line endings. This tool fixes them in one step and shows exactly how many spaces, tabs and line breaks were removed or changed.

Every operation can be switched on or off. Show whitespace displays the result with spaces as ·, tabs as →, special spaces as ° and line breaks as , so you can check it before copying.

How to use it

  1. Paste your text, or use Open file (or drop a file on the box) to load a text file from your device.
  2. Tick what to remove: leading and trailing spaces on each line, repeated spaces between words, blank lines — or all whitespace at once.
  3. If needed, convert Tabs to spaces (or indentation to tabs) with your tab width, and choose the Line endings: keep, LF (Linux, macOS) or CRLF (Windows).
  4. Check the counts, turn on Show whitespace to inspect the result, then copy or download it.

Examples

Fix spacing in text copied from a PDF
Input
The  quick   brown fox  
  jumps over   the lazy dog. 
Result
The quick brown fox
jumps over the lazy dog.
Remove all whitespace from a phone number
Input
+91 98765 43210
Result
+919876543210

Uses Remove all whitespace, including line breaks.

Turn tab indentation into 2 spaces
Input
	if (ready) {
		start();
	}
Result
  if (ready) {
    start();
  }

Tabs → spaces with a tab width of 2, and Leading spaces unticked so the indentation is kept.

Common uses

  • Cleaning up text pasted from PDFs, Word documents and web pages before publishing or translating it.
  • Removing trailing spaces and converting tabs before committing code or config files.
  • Making lists and spreadsheet data match exactly by removing hidden spaces and no-break spaces.
  • Converting Windows (CRLF) files to Unix (LF) line endings, or the other way round.

What counts as whitespace

Normal spaces and tabs, line breaks (LF, CRLF and CR), and the Unicode spaces that look like a space: the no-break space (U+00A0,   in HTML), the narrow no-break space (U+202F), figure, punctuation, en, em, thin and hair spaces (U+2000–U+200A), the medium mathematical space (U+205F), the Ogham space mark (U+1680) and the ideographic space (U+3000) used in Chinese and Japanese text.

Zero-width characters such as the zero-width space (U+200B) are not whitespace. Remove them with the Text Cleaner.

Order of operations

  1. Special spaces become normal spaces.
  2. Leading whitespace is trimmed from each line.
  3. Trailing whitespace is trimmed from each line.
  4. Runs of two or more spaces between words become one space. Indentation at the start of a line is not touched, and runs made only of tabs are kept so tab-separated columns stay intact.
  5. Blank lines are removed.
  6. Tabs are expanded to spaces, or leading spaces are turned into tabs. This comes after the clean-up, so tab stops are counted on the cleaned line.
  7. Line endings are kept or converted.

Remove all whitespace replaces all of these steps: it deletes every space, tab, line break and special space.

Tabs and tab stops

Tabs → spaces expands each tab to the next tab stop, the way code editors display it, so columns stay aligned. With a tab width of 4, a tab after ab becomes two spaces (to reach column 4), not four. Tabs are expanded after the other clean-up steps, so the spaces a tab becomes are not collapsed, even with Repeated spaces between words ticked. Leading spaces → tabs rewrites only the indentation at the start of each line and keeps its visual width; any leftover spaces stay as spaces.

Line endings

Windows ends each line with CRLF (\r\n); Linux and macOS use LF (\n). Choose LF or CRLF to convert every line, or Keep to leave each line's ending exactly as it was. When you open a file, its line endings are detected and shown under the box. Text typed or pasted into the box always uses LF, because browsers normalise line breaks in text boxes.

Limitations

  • Collapsing repeated spaces also affects spaces inside quoted strings in code. Untick it when cleaning source code where spacing inside strings matters.
  • Tab stops are counted in characters. Wide characters such as Chinese or emoji count as one column, as in most code editors.
  • Show whitespace previews the first 200,000 characters; Copy and Download always use the complete result.

Privacy

Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

Frequently asked questions

How do I remove double spaces between words?

Keep Repeated spaces between words ticked. Every run of two or more spaces between words becomes a single space (mixed spaces and tabs count too). Indentation at the start of a line is kept unless Leading spaces is also ticked, and runs of tabs alone are kept so tab-separated data is not damaged.

What is a no-break space, and why remove it?

A no-break space (U+00A0,   in HTML) looks like a normal space but stops a line from breaking at that point. Text copied from web pages and Word often contains them, and they make searches, spreadsheet formulas and comparisons fail, because a no-break space is a different character from a normal space. Convert no-break and special spaces replaces them with normal spaces.

How do I convert Windows line endings to Unix?

Open the file with Open file, choose Line endings: LF (Linux, macOS), then download the result. Choose CRLF (Windows) for the opposite direction.

Does "Remove all whitespace" also remove line breaks?

Yes. It removes every space, tab, line break and special space and leaves one continuous line. To keep the lines, use the other options instead.

Is my text uploaded?

No. The clean-up runs in your browser and nothing you paste or open is sent to a server.

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.