Whitespace Cleaner
BetaClean 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.
- Free, no sign-up
- REST + MCP
- Updated
- Reviewed by Olgun Ozoktas
Options
Lines: 0
Lines: 0
How to clean whitespace in text
-
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. -
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. -
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. -
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
Spreadsheet cells and tables
Files that mix line endings
Forms with length limits
Why use a whitespace cleaner?
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.