Text tool

Whitespace Cleaner

Remove extra spaces, trailing whitespace, irregular blank lines, and tabs from pasted text with independent checkboxes for each transformation.

Output

How each whitespace option works

Five independent checkboxes control whitespace cleanup. Trim outer whitespace, on by default, removes leading and trailing whitespace from the entire text. Remove trailing whitespace, also on by default, strips spaces and tabs from the end of each line, leaving the line break. Collapse repeated spaces, off by default, replaces any run of two or more consecutive spaces with a single space, but does not affect tabs or line breaks. Normalize blank lines, off by default, reduces any sequence of three or more newlines to exactly two newlines (one blank line between paragraphs). Convert tabs to four spaces, off by default, replaces every tab character with four space characters throughout the text.

The transformations execute in a specific order: tabs are converted first, then trailing whitespace is removed, then repeated spaces are collapsed, then blank lines are normalized, and finally the entire text is trimmed at the edges. Only enabled options run, so disabling all checkboxes leaves the text unchanged. The output shows the result of all selected transformations applied together.

Cleaning a spreadsheet column pasted as text

  • Input (from a messy spreadsheet export): " apple ", " banana ", " cherry "
  • Enable Trim outer whitespace and Remove trailing whitespace: "apple", "banana", "cherry"
  • Enable Collapse repeated spaces on input "one two three": "one two three"
  • Apply all five options to mixed text with tabs and irregular blanks: consistent spacing, no leading/trailing whitespace, tabs replaced with spaces
  • Disable Normalize blank lines if you want to preserve intentional paragraph spacing and only clean indentation

Data preparation from pasted code and tables

When copying code from an IDE or a web page into a plain-text format, indentation often becomes irregular, with extra spaces or tabs misaligned. Enable Convert tabs to four spaces to standardize indentation across systems, then enable Collapse repeated spaces if accidental double-spaces appear. Trim outer whitespace removes any stray leading spaces before the first line of code.

For table data pasted from spreadsheets, enable Trim outer whitespace and Remove trailing whitespace to clean each cell entry. Many spreadsheet applications add leading or trailing spaces when exporting to plain text. If columns were separated by multiple spaces, enable Collapse repeated spaces to reduce them to single spaces for easier parsing or re-import. Normalize blank lines is less useful here unless blank rows are part of the export.

Specific cleaning scenarios and cautions

  • Cleaning email headers and body text: enable Trim outer whitespace and Remove trailing whitespace to strip accidental spaces, but leave Collapse repeated spaces off if multiple spaces carry meaning.
  • Preparing CSV data: enable Trim outer whitespace and Remove trailing whitespace so quoted fields do not contain leading or trailing spaces, but avoid Collapse repeated spaces if your actual data contains intentional multi-space separators.
  • Normalizing markdown or code comments: enable Collapse repeated spaces and Normalize blank lines to fix irregular formatting while preserving paragraph structure.
  • Reformatting mixed-indent text (tabs and spaces): enable Convert tabs to four spaces first, then Collapse repeated spaces to unify mixed indentation, though this may alter intentional formatting.
  • Caution: Normalize blank lines removes all but one blank line between paragraphs, which can merge sections that were deliberately separated by multiple line breaks for visual separation.

Frequently asked questions

What is the difference between Trim outer whitespace and Remove trailing whitespace?

Trim outer whitespace removes leading and trailing whitespace from the entire text (beginning and end). Remove trailing whitespace removes spaces and tabs from the end of each individual line, leaving line breaks intact.

Does Collapse repeated spaces affect tabs or line breaks?

No. Collapse repeated spaces only merges two or more consecutive space characters into one space. Tabs and line breaks are not affected by this option.

Can I preserve intentional multi-space indentation?

Yes. Leave Collapse repeated spaces unchecked. This option is off by default to protect intentional spacing. Enable it only when you want to reduce multiple spaces to single spaces.

What does Normalize blank lines do to my paragraph spacing?

It reduces any sequence of three or more newlines down to two newlines, creating at most one blank line between sections. If your text uses two or more blank lines for visual separation, some will be removed.

Why would I convert tabs to spaces?

Some editors, parsers, or online forms do not display tabs correctly and may treat them as variable-width characters. Converting tabs to four spaces ensures consistent alignment and compatibility across platforms.

Why are some wide gaps in my pasted text not collapsing?

Collapse repeated spaces only matches ordinary space characters. Text copied from web pages or Word often contains non-breaking spaces, which look identical but are a different character and survive the collapse. Retype those gaps as normal spaces, or check whether the gap is a tab and enable Convert tabs to four spaces followed by Collapse repeated spaces.