Skip to content

Text

Whitespace Cleaner

Whitespace Cleaner

Beta

Clean up whitespace in pasted text. Trim the ends, collapse runs of spaces and tabs, remove blank lines, and normalize Windows line endings. Runs in your browser, no signup.

Use via API
  • Free, no sign-up
  • REST + MCP
  • Updated
  • Reviewed by Olgun Ozoktas

Options

Lines: 0

Lines: 0

How to clean whitespace in text

  1. Paste the text

    Paste the text into the Input box. The cleaned version appears in the output box at once, and the counters show how many characters and lines changed.
  2. Choose the fixes

    Turn the four toggles on or off. Trim and Collapse spaces are on by default. Remove blank lines is off, because many users want to keep paragraph breaks. Normalize line endings is on.
  3. Check the counters

    Compare the characters before and after. A large drop usually means Windows line endings or a tab-separated table were in the input.
  4. Copy the result

    Click Copy to put the cleaned text on your clipboard, then paste it into your document, form, or file.

Common use cases

Text copied from a PDF

PDF text comes out with a line break after every printed line and double spaces between words. Collapse spaces and trim fix the spacing in one pass.

Spreadsheet cells and tables

A pasted table carries tabs between the columns and padding spaces inside the cells. Collapse spaces turns it into plain, single-spaced text.

Files that mix line endings

A file edited on Windows and on macOS shows ^M marks and noisy diffs. Normalize line endings converts it to LF before you commit.

Forms with length limits

A bio, a product description, or a meta description must fit a character limit. Removing hidden whitespace recovers characters without changing the words.

Why use a whitespace cleaner?

Text copied from a PDF, a web page, a spreadsheet, or a chat window carries spacing you did not write: double spaces after a paste, tabs where a table used to be, blank lines between every paragraph, and Windows line endings that show up as ^M in a Unix editor. Fixing that by hand means a long series of find-and-replace runs. The Whitespace Cleaner applies the four common fixes in one pass and shows you how many characters it removed, so you can paste the result into a document, a form, or a script with confidence.

The Whitespace Cleaner removes the spacing that gets into text on the way from one program to another. A PDF export, a spreadsheet, a chat window, and an email client each add their own spaces, tabs, blank lines, and line endings. The tool applies four fixes in one pass: trim the ends, collapse runs of spaces and tabs, remove blank lines, and normalize line endings to LF. Each fix is a toggle, so you can keep paragraph breaks or keep indentation when you need them.

The cleaning function is the same one that runs behind the REST API and the MCP server, so a script or an AI client gets exactly the result the page shows. The page adds counters for characters before and after, characters removed, and lines before and after, so you can see what changed before you copy the result.

For more control over spacing, pair this tool with Find & Replace, which handles regular expressions such as trailing spaces at the end of each line. Use the Duplicate Line Remover to drop repeated entries from a cleaned list, and the Text Line Sorter to order the lines afterwards.

How it compares

A text editor can do each of these fixes with a separate find-and-replace, and a shell can do them with sed or tr, but both need the exact pattern for each case and a way to see what changed. A dedicated whitespace cleaner makes the four fixes explicit toggles and reports the counts, which is faster for a one-off paste and safer for someone who does not want to write a regular expression.

Compared with other online whitespace tools, this one runs the cleaning in your browser rather than on a server, offers the same function through a REST endpoint and an MCP server for automation, and states exactly what each option does. It does not attempt to detect code or quotes, so use the toggles, and use Find & Replace when a pattern needs more precision.

Tips

  • Turn Collapse spaces off before you clean Python, YAML, or Makefile text. Those formats depend on leading whitespace.
  • Keep Remove blank lines off for prose. Paragraph breaks are blank lines, and dropping them merges the paragraphs.
  • Use Normalize line endings before a Git commit when a file shows ^M marks in the diff.
  • Run the Duplicate Line Remover after this tool when a pasted list repeats entries. Cleaning first makes the duplicate check exact.
  • Watch the Characters removed counter. A zero means the input was already clean, so a leftover spacing problem is something other than whitespace.

Frequently Asked Questions

What does the Whitespace Cleaner change?

It applies up to four fixes, and each one is a toggle. Trim removes whitespace before the first character and after the last one. Collapse spaces turns every run of spaces and tabs inside a line into one space. Remove blank lines drops lines that hold only whitespace. Normalize line endings converts CRLF and CR to LF. It does not change letters, punctuation, or the order of your lines.

Does it remove the indentation from code?

Yes, when Collapse spaces is on. That option turns leading tabs and spaces on each line into one space, which breaks Python and YAML. Turn Collapse spaces off to keep indentation and still trim the ends, remove blank lines, and normalize line endings.

Does it remove non-breaking spaces?

Yes. Collapse spaces treats a non-breaking space (U+00A0) and the other Unicode space characters as whitespace, so a run of them becomes one regular space. Trim removes them at the ends of the text as well.

What is the difference between CRLF and LF?

CRLF is the two-character line ending Windows writes. LF is the one-character line ending used by Linux, macOS, Git, and most web tooling. A file that mixes the two shows stray ^M marks in some editors and produces noisy diffs. Normalize line endings converts every CRLF and every lone CR to LF.

Is there a size limit?

The page has no fixed limit; your browser's memory is the ceiling, and a very large paste takes a moment to process. The REST and MCP surfaces cap one request at 1 MB.

Does the Whitespace Cleaner require a signup?

No. It is available with no signup and no usage limits. The cleaning runs in your browser, so the text you paste is not uploaded to a server.

Can I run the same cleanup from a script or an AI client?

Yes. The same function powers the REST endpoint at api.findutils.com and the MCP server at mcp.findutils.com, as the REST tool whitespace-clean and the MCP tool whitespace_clean. The four options are the same arguments: trim, collapse_spaces, remove_blank_lines, and normalize_newlines.

Does it remove trailing spaces at the end of each line?

Collapse spaces reduces trailing spaces on a line to a single space. It does not remove that last space on its own. To remove every trailing space, use the Find & Replace tool in regex mode with the pattern [ \t]+(?=\n|$) and an empty replacement.

Will it change the text inside quotes or code blocks?

Yes. The tool applies each fix to the whole input. It does not detect quotes, Markdown, or code fences. Clean those sections separately if their spacing matters.

Why does the character count drop more than I expected?

Each CRLF line ending counts as two characters and becomes one after normalization, so a Windows file with 500 lines loses about 500 characters from that step alone. Tabs, double spaces, and blank lines add to the total.

Rate This Tool

0/1000

Get Weekly Tools

Suggest a Tool