Free Whitespace Cleaner
Remove extra spaces, trim lines, collapse blank lines, and normalise line endings in any text. Clean up copy-pasted content in one click.
or drop a .txt, .csv, .md or .log file on the box
Cleaning options
Common uses
- Clean Copy-Pasted TextFix messy formatting from Word, PDFs, and web pages — remove extra spaces, double blank lines, and inconsistent indentation.
- Clean Whitespace in Code and Config FilesRemove trailing spaces, normalise line endings, and fix indentation issues in code and configuration files.
- Clean Text for Content Management SystemsNormalise text before pasting into WordPress, Contentful, or other CMS platforms to prevent formatting issues.
- Clean Whitespace in Data FilesRemove leading/trailing spaces from data values before importing into databases, spreadsheets, or data pipelines.
- Clean Whitespace in Email TemplatesNormalise spacing in email copy before sending — prevents rendering inconsistencies across email clients.
How It Works
Whitespace Cleaner runs entirely in your browser using hand-written JavaScript regex — no library, no server. Every transformation happens locally as you type, with results updating in real time.
- 1Input scanning and statsAs you type or paste, the tool scans your text with targeted regex patterns to count trailing-space lines, consecutive blank lines, tab characters, Unicode spaces (NBSP, full-width), and invisible zero-width characters. These counts appear immediately beneath the input so you can see what is actually wrong with your text before cleaning anything.
- 2Line-by-line regex transformationsThe clean() function splits on newlines and applies your chosen options in order: tabs are replaced or collapsed, runs of spaces are reduced to one with /[ \t]+/g, then each line is trimmed. Unicode spaces ( , – , and others) are replaced with regular spaces; zero-width characters (–, ) are deleted entirely. Smart punctuation like curly quotes and em-dashes is straightened to ASCII equivalents.
- 3Empty-line and document trimmingAfter per-line work, consecutive blank lines are either removed entirely or collapsed to a single blank (whichever option you picked) using a single /\n{3,}/ replacement. Leading and trailing newlines for the whole document are stripped last, keeping the logic predictable regardless of option order.
- 4Line-ending normalization and outputThe tool detects the dominant line ending of the original text (LF, CRLF, or CR) before normalization so the 'Keep original' option can restore it faithfully. You can also force a specific convention. The cleaned text appears instantly in the output pane, with a before/after stats panel showing character and line counts removed, and a Download .txt button that builds a Blob locally.
Related Tools
Background Noise Remover
Remove background noise, wind, traffic, hiss and hum from voice recordings with an AI model that runs on your device. Nothing is uploaded and no account is needed.
Printable Paper — Lined, Graph, Dot Grid and Music Paper (PDF)
Print your own paper: lined (wide or college ruled), graph, dot grid, isometric, handwriting practice, music staff or Cornell notes, in A4, Letter, A5 or Legal, any line colour, as many pages as you need. A sharp vector PDF made in your browser.
Remove Accents (Diacritics)
Strip accents and diacritics from text for slugs, filenames or ASCII — with accurate Vietnamese (đ→d, tone marks) and a slugify mode. Free, private, in your browser.