Skip to content
TextLab

Free whitespace remover

Whitespace remover that names what it found

Trim the indents and trailing spaces, squeeze runs of spaces down to one, and turn tabs into the number of spaces you want — free, without a signup, on text of any length. What this page adds is the part ordinary trimming misses: it detects twenty-four characters that are blank without being the space bar, tells you what each one is called and where it came from, and converts or deletes them. That is why a line that looks empty stays empty and a phrase that refused to match a search suddenly does.

  • 100% free
  • No signup
  • 24 invisible characters named
  • Tabs to 1, 2, 4 or 8 spaces
  • Shows where each one sits
0characters swept out0 kinds of invisible character identified by name
The ones you can see
The ones you cannot

0
Runs squeezed
0
Tabs converted
0
Line edges trimmed
0
Characters now

How to strip unwanted whitespace

Three steps, and the diagnosis arrives before you touch a single option.

  1. Paste the text whose spacing is misbehaving

    Put the offending lines in the top box. Nothing has to be selected first: ⌘V, or Ctrl+V on Windows, lands your clipboard in the box wherever the cursor happens to be. The marked-up view further down redraws on the same keystroke, so the shape of the problem is visible before you have decided anything.

  2. Read the table before you change anything

    If your text contains anything more exotic than the space bar, the table names it, says where that kind of character usually comes from, gives its Unicode number and counts how many are in your text. This is the part ordinary trimming skips: a line that looks blank because it holds one non-breaking space, or a phrase that will not match a search because a thin space sits in the middle of it.

  3. Choose the treatment and copy the result

    The left column handles the spaces you can see — squeezing runs to one, cutting indents and trailing spaces, and turning tabs into one, two, four or eight spaces. The right column handles the ones you cannot: converting the fourteen lookalike spaces into the ordinary kind and deleting the ten widthless characters. Tick the last box on the left if you want no spaces at all between the words.

Technical specifications

Lookalike spaces recognised14: the non-breaking space, the narrow non-breaking space, thin, hair, figure, punctuation, en, em, three-per-em, four-per-em, six-per-em, medium mathematical, ideographic and ogham
Widthless characters removed10: zero-width space, zero-width non-joiner, zero-width joiner, word joiner, byte order mark, soft hyphen, Mongolian vowel separator and the three direction marks
Trimming optionsFront of each line, end of each line, and the blank space above and below the whole text — each independent of the others
Tab conversionLeave as tabs, or replace each with 1, 2, 4 or 8 spaces; the count of tabs converted is reported
Run collapsingAny sequence of two or more spaces or tabs becomes one space; line breaks are never touched, so nothing reflows
What the report gives youFor every invisible character found: its plain-English name, where that kind usually comes from, its U+ number and how many are present
Marked-up viewFirst 4,000 characters, with a distinct mark for ordinary spaces, tabs, lookalike spaces, widthless characters and line ends
Price and processingFree, no signup; every pass runs inside this browser tab

Frequently asked questions

What is a non-breaking space?

It is a space that looks completely normal but behaves differently: nothing is allowed to break the line at that point. Typesetters use it to keep a number attached to its unit, so 10 kg never splits across two lines, and to hold a name together as Dr Watson. Word inserts them automatically, web pages are full of them, and they look identical to the space bar on your keyboard at every zoom level. The difference only shows up when a search for two words separated by an ordinary space fails to find a phrase that visibly contains it.

Why does search-and-replace miss some of the spaces in my document?

Because it is looking for one character and your document contains several different ones that all look the same. Unicode defines around fourteen characters whose entire job is to be blank, and the space bar produces only one of them. A find box searching for a plain space will step straight past a thin space in a French quotation, a figure space in a financial table, or a full-width space typed on a Japanese keyboard. The table above finds every one of them by name and counts them, which is usually the moment the mystery resolves.

Where do zero-width spaces come from and why do they matter?

They come from web pages, where they mark a point at which a long web address or product code is allowed to wrap, and they survive being copied even though they occupy no width at all. Because they occupy no width, a code or an email address that looks perfect can fail validation, a spreadsheet lookup can miss a match, and a password field can reject an entry you copied correctly. They are the single most common cause of a value that is obviously right being rejected as wrong.

Does this remove line breaks as well?

No — line breaks are deliberately left alone, however you set the options. Even the last box, which strips out every space and tab, keeps your line structure exactly as it was, because collapsing the lines is a different operation with different questions attached to it. Rejoining broken lines needs decisions about hyphens and paragraph gaps that have no place here.

How is this different from the TRIM function in Excel or Google Sheets?

TRIM handles the ordinary space and nothing else, which is why it so often appears to do nothing. Excel's TRIM removes leading and trailing spaces and reduces internal runs to one, but it treats a non-breaking space as an ordinary character and leaves it exactly where it is — the classic reason a cleaned column still refuses to match. There is also no tab handling and no way to see what was found. Paste the column here, convert the lookalikes, and paste it back.

Why is my text still the same length after trimming?

Almost always because the spaces at the ends of the lines were not spaces. A trailing non-breaking space is not whitespace as far as most trimming code is concerned, so it survives the trim and keeps the line looking padded. Switch on the conversion in the right-hand column first: once the lookalikes have become ordinary spaces, the trim finds them and the count moves.

What does the marked-up view underneath actually show?

Every gap in your text, drawn as a printable character so you can locate it. A middle dot is an ordinary space, an arrow is a tab, a highlighted box is one of the lookalike spaces, a second highlight is something widthless, and a pilcrow marks the end of each line. It renders the first 4,000 characters, which is enough to find the pattern; the cleaning itself has no limit.

The fourteen spaces that are not the space bar

Ask anyone how many space characters there are and the answer is one. Unicode counts about fourteen, and the difference is the source of an entire genre of unexplainable bug. The most common of them is the non-breaking space, a space that looks exactly normal but refuses to let a line break at that point: typographers use it so that 10 kg and Dr Watson never split across two lines, HTML has written it as   since the beginning, and Word inserts it on your behalf without telling you. Its relatives are more specialised — a thin space either side of a dash, a figure space exactly as wide as a digit so that a column of numbers lines up, a full-width space produced by every Chinese and Japanese keyboard. None of them are mistakes at the point they were created. They only become mistakes when the text is moved somewhere that expects the ordinary kind.

Then there are the ones with no width at all, which are stranger still. A zero-width space is inserted by web pages to say “this long address may wrap here”; a byte order mark sits at the front of a file to declare its encoding; a soft hyphen marks a place a word could be split, and stays invisible until it is. All three survive being copied. An order number that looks perfect is rejected as invalid, a spreadsheet lookup returns nothing for two cells that plainly read the same, a copied password is refused — and nothing on the screen accounts for any of it, because there is nothing on the screen to see. This is where a character counter earns its keep as a diagnostic: when the count is one higher than the number of characters you can see, one of these is sitting in there.

Beyond the invisible characters, the ordinary ones follow rules of their own. Trailing spaces at the end of lines are the most common form of clutter in shared documents and the hardest to spot, since nothing renders them. Indentation pasted out of a code editor arrives as tabs, which jump to the next field rather than the next character when they land in a form or a spreadsheet cell. The double space after a full stop is a typewriter habit that persists in decades of documents and that every modern style guide now rejects. All three are handled on the left above, independently, so you can squeeze runs without touching indentation or trim ends without touching anything else. When the spacing is only part of the problem, the text cleaner runs these same operations alongside typography and line-layout fixes in one pass.

Where your text is examined

The scan and every conversion run in this browser tab on JavaScript that came with the page, so the spreadsheet column, client list or draft you paste is never transmitted and never stored. Nothing is remembered between visits, including the option settings. Because the detection is local, it works just as well on a document you are not allowed to upload anywhere as on one you are.