Skip to content

Text Cleaner

Trim the ends and fold repeated spaces, tabs, and line breaks into one space. The page does not store the text.

Result

Enter text

How to Use

  1. 1 Paste up to 5000 characters.
  2. 2 Choose Clean the text.
  3. 3 Copy the single-spaced result.

Example Output

  • A line with extra spaces becomes one space between words.

About This Tool

The words stay in order. Only the extra whitespace changes.

Using the Text Cleaner

This page trims the ends of the text and folds spaces, tabs, and line breaks into a single space. Hello followed by three spaces and then world becomes Hello world. The words stay in order. Hello is still first, and world is still second. The three spaces do not become three spaces, and they do not disappear so that the words run together. One space remains between them. The page does not store the text. The cleaned line is shown for you to copy. A later visit does not remember it.

The field accepts from 1 to 5000 characters. The count is the length of what you entered, before the fold. A blank field is rejected. A string longer than 5000 characters is rejected. The message is Enter from 1 to 5000 characters. Hello and world, with the three spaces between them, is well inside that limit. After cleaning, the result is shorter by the extra spaces that were folded, and the page shows how many characters went in and how many came out.

Tabs and line breaks are whitespace, so they fold the same way spaces do. A tab between Hello and world becomes one space. A line break between them becomes one space. Several line breaks in a row become one space, not a blank line. The ends are trimmed, so spaces or line breaks before Hello or after world are removed rather than kept as a single space at the edge. The words that remain stay in the order you typed them. Case stays. Hello does not become hello, and it does not become HELLO. The three-space sample is the check: the capital H, the small w, and a single space between the words, with the page storing nothing after you leave.

Punctuation stays attached to the word it was attached to, except that the whitespace around it is folded. A comma after Hello remains a comma. The page does not rewrite sentences, and it does not store a copy for later. If you need the original with the three spaces, keep that original yourself. Running the cleaned Hello world through the page again leaves Hello world, because there is no extra whitespace left to fold.

What the Fold Changes

The fold touches whitespace and the ends of the string. Spaces, tabs, and line breaks are treated as whitespace. Each run of them becomes one space, and then the ends are trimmed. Hello followed by three spaces and world becomes Hello world. The character count going in includes the three spaces. The character count coming out is the length of Hello world, with one space. The headline is that output length. The words are the same words, in the same order. Nothing is stored.

How Three Spaces Become One

Enter Hello, then three spaces, then world. The page sees one run of spaces between two words. It replaces that run with a single space and trims the ends, which changes nothing further if you did not pad the ends. The result is Hello world. Enter the same words with a tab instead of the three spaces. The result is Hello world again. Enter them with a line break between them. The result is Hello world again. The order does not flip. world never moves in front of Hello. The length must be from 1 to 5000 characters, or the page rejects the text and shows nothing cleaned. The page does not store the text either way.

Joining wrapped lines is a different choice. The Remove Line Breaks page joins wrapped lines without deleting the words, and you choose whether a blank line between paragraphs should remain. It does not, by itself, describe the three-space sample as Hello world with every tab and line break folded. Use it when you want that line-break choice. Use this page when every run of spaces, tabs, and line breaks should become one space and the ends should be trimmed.

What the Words Keep

The words keep their spelling, their case, and their order. Hello world is not rephrased. A repeated word stays repeated. If you typed Hello Hello with extra spaces between the two Hellos, the result is Hello Hello with one space. The page does not decide that the second Hello was a mistake. It does not store the text, so it also does not build a list of words you have cleaned before. Each run looks only at the string in the field.

Hello, Three Spaces, and world

Type Hello, three spaces, and world. Confirm the result is Hello world. Confirm the words are in that order and that the capital H is unchanged. The characters-in count should include the three spaces. The characters-out count should match Hello world. Put a line break between the two words instead of the three spaces and confirm the result is still Hello world. Put spaces before Hello and after world and confirm those end spaces are gone, while the single space between the words remains. Enter more than 5000 characters and confirm the rejection Enter from 1 to 5000 characters. Clear the field and confirm a blank value is rejected with that same message. The page does not store any of these strings.

A count of blocks separated by blank lines is a different reading. The Paragraph Counter counts paragraphs separated by a blank line, and it shows the words and characters inside them. It does not fold those blank lines into a single space the way this page folds the three spaces between Hello and world. Use it when you want that count. Use this page when you want the single-spaced line.

The 5000 Character Limit

The text you enter must be from 1 to 5000 characters. The three-space sample is far below that. A string of 5000 characters is accepted, then trimmed and folded. A string of 5001 characters is rejected with Enter from 1 to 5000 characters. The page does not keep the first 5000 and clean those. It does not store the rejected string. An empty field is rejected with the same message. A field that contains only spaces, tabs, or line breaks is also rejected, because after the whitespace is considered there is no text left to clean. The limit is on the input length, not on the length after folding.

Mistakes That Expect a Rewrite

The usual miss is to expect the page to change case. Hello stays Hello. Another miss is to expect three spaces to vanish completely so the result is Helloworld. The result is Hello world, with one space. A third miss is to expect a blank line between paragraphs to remain a blank line. Line breaks are whitespace, and a run of them becomes one space. A fourth miss is to expect the page to store the text so you can return for it. The page does not store the text. A fifth miss is to paste 5001 characters and look for a partial clean. The whole value is rejected with Enter from 1 to 5000 characters.

A tally of sentences is a different pass over the same kind of text. The Sentence Counter counts sentences that end with a period, a question mark, or an exclamation mark. A decimal point between digits does not end a sentence. It does not turn three spaces into one, and it does not return Hello world as a cleaned line. Use it when you want that count. Use this page when you want the whitespace folded.

Copying the Single Spaced Line

Keep the original and the cleaned line in the same note until you have checked the words. For the sample, the original has Hello, three spaces, and world. The cleaned line is Hello world. Check the order, the capital H, and the single space. If the original had a tab or a line break, write that those were folded too, so a later reader knows why the line is flat. The page does not store the text, which means the note is the only record. Copy the characters-out count if the length matters, and remember that the characters-in count included the extra whitespace.

Cleaning the Sample Again

Enter Hello, three spaces, and world. Confirm the result is Hello world, that the words are in that order, and that the ends have no extra space. Replace the three spaces with a line break and confirm Hello world again. Replace them with a tab and confirm Hello world again. Put three spaces before Hello and confirm the result still starts at H. Enter a string longer than 5000 characters and confirm Enter from 1 to 5000 characters. Enter nothing and confirm that same message. Run Hello world, already clean, and confirm it stays Hello world. Leave the page and come back. The earlier line should not be waiting, because the page does not store the text.

Upper case is a different change to the same letters. The Uppercase Converter turns the text you type into upper case. hello becomes HELLO. It does not fold three spaces into one as its job, and it does not leave Hello world in its original case. Use it when you want HELLO. Use this page when you want the spacing cleaned and the letters left as typed.

Using the Cleaned Line

The cleaned line is the text after the trim and the fold, ready to copy. Hello world is the sample. It is not stored, and it is not sent anywhere by this page. You can paste it into a note, a message, or a field that rejected the extra spaces. If that field has its own limit, the limit that matters there is its limit. This page only enforces 1 to 5000 characters on the way in, then shows the shorter or equal result.

Checking the Ends and the Gap

Start with the sample. Hello, three spaces, and world should become Hello world. Then add spaces at both ends and confirm they are gone while the middle space remains. Then use a tab and a line break in place of the three spaces and confirm each one still produces Hello world. Then exceed 5000 characters and confirm the rejection. The words in a successful result should be readable in the original order, with case unchanged. The page does not store the text, so copy the line before you clear the field. A second run of Hello world should match the first cleaned result exactly.

Changing case is a separate pass. The Online Text Case Converter can turn Hello World into HELLO WORLD, into hello world, or into title case from a lowercase line. It does not claim the three-space fold as its result. Use it when you want a case change. Use this page when the letters should stay and the extra whitespace should not.

Frequently Asked Questions

What does Hello followed by three spaces and world become?

Hello world. The three spaces fold into one space. The words stay in that order, and the page does not store the text.

Do tabs and line breaks fold the same way?

Yes. Spaces, tabs, and line breaks are whitespace. A run of them between Hello and world becomes one space.

What happens at the ends?

The ends are trimmed. Spaces, tabs, or line breaks before the first word or after the last word are removed rather than kept as a space.

Do the words get reordered or respelt?

No. Words stay in order. Hello stays Hello. The page does not change case and does not join the words into Helloworld.

How long can the text be?

From 1 to 5000 characters. A longer string is rejected with Enter from 1 to 5000 characters. The page does not clean a clipped portion.

What if the field is blank?

It is rejected with Enter from 1 to 5000 characters. A field of only spaces, tabs, or line breaks is rejected as well, because trimming leaves nothing.