Whitespace cleaner
Paste text copied from Word, a PDF or a spreadsheet to clean repeated spaces, whitespace at line edges, blank lines and invisible special spaces. You first see a preview and how many changes each rule would make; your text only changes when you press “Apply to input”. With the default rules the preview already shows the text after you remove extra spaces between words and at line edges and collapse runs of blank lines, with nothing to set up.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Paste your text into the input box.
- Choose the rules you want; the number next to each rule shows how many changes it would make.
- Check the preview, and turn on “Show invisible characters” if you want to see spaces and tabs.
- Copy or download the result, or press “Apply to input” to replace your text with it.
Example
The built-in example has 7 lines: an Arabic line with spaces at both ends and between words, an English line that starts with a tab and contains a non-breaking space, three blank lines, a price line with two special spaces and a trailing zero-width space, and a Persian word with ZWNJ next to a family emoji.
The default rules make 13 changes: 3 special spaces replaced, the start of 3 lines and the end of 2 lines trimmed, 3 runs of spaces collapsed and 2 blank lines removed. The text becomes 5 lines starting with “مرحبًا بكم في متجرنا”, and the Persian word and the family emoji stay intact because both zero-width rules are off.
Limits and caveats
- Tested with 100,000 lines (about 1.5 MB): cleaning is computed in well under a second, but the browser text box itself needs several seconds to display a paste of that size. For long results the preview shows only the first 300 lines; copy, download and “Apply to input” use the full result. Above about 4,000 lines or 150,000 characters the text box shows every line in one direction (taken from its first letter) instead of a direction per line, because per-line direction makes the browser extremely slow at that size.
- Tab conversion replaces every tab with a fixed number of spaces and does not align columns. Collapsing affects ordinary spaces only and keeps the indentation at the start of a line unless start trimming is on.
- The browser text box converts CRLF to LF when you paste, so the line-ending counter is usually zero except for the Unicode separators U+2028, U+2029 and U+0085. Choose CRLF in the line-ending list if you need a Windows file.
- The tool does not remove direction marks (LRM, RLM and similar) or soft hyphens, and it never changes punctuation or diacritics.
Questions about this tool
Why is the rule that removes ZWNJ and ZWJ off by default?
Because these two invisible characters carry meaning: ZWNJ separates word parts in Persian (میخواهم) and is used in Urdu and Kurdish, and ZWJ controls how Arabic letters join and glues combined emoji such as the family emoji together. Removing them can change how words look or split one emoji into several. Turn the rule on only if you are sure your text does not need them.
What is a non-breaking space and why replace it?
It is a character that looks like a space (NBSP) but prevents a line break at that point; Word and web pages add it. It looks normal yet breaks search, matching and word splitting in spreadsheets and shop systems. Replacing it with a normal space is usually safe, unless you rely on it to keep a number and its unit on one line.
Does my original text change automatically?
No. The input stays as it is and the result appears in the preview. Your text is replaced only when you press “Apply to input”, and you can press “Undo” afterwards to get the previous text back.
How do I remove extra spaces between words?
Just paste the text: “Collapse repeated spaces into one” is on by default, together with trimming at the start and end of each line. A line with four spaces between “Hello” and “world” and a trailing space becomes “Hello world”, counted as two changes: one run of spaces collapsed and one trailing space trimmed. Then copy the result or press “Apply to input”.
How do I remove blank lines from text?
Choose “Remove all blank lines” in the “Blank lines” list. The default is “Collapse several blank lines into one”, which keeps paragraphs apart; removing them all puts every line directly after the previous one. A line that contains only spaces counts as blank.
