Remove extra spaces and blank lines
Trim lines, collapse repeated spaces, remove or collapse blank lines, convert tabs and spaces, and strip invisible characters.
0 / 2,000,000 characters · Updates as you type.
Text copied from PDFs, web pages, Word documents and spreadsheets carries whitespace you cannot see: double spaces, trailing spaces, runs of blank lines, tabs, non-breaking spaces (U+00A0) and zero-width characters (U+200B, U+FEFF) that break searches, form validation and code. This cleaner removes them in one pass, with each step under your control.
Trimming can remove spaces at both ends of each line, or only trailing spaces so code indentation survives. Collapsing turns runs of spaces and tabs inside a line into one space but leaves the indentation at the start of the line alone. Blank lines can be collapsed to a single empty line (keeping paragraphs) or removed entirely. Tab conversion is column-aware: tabs expand to the next tab stop rather than a fixed number of spaces, and "leading spaces to tabs" re-indents with tabs without touching alignment inside the line.
Unicode cleanup replaces non-breaking and other special spaces with a normal space and removes zero-width spaces and byte-order marks. Zero-width joiners and non-joiners are kept inside words, where Persian text and emoji sequences need them, and removed only at word edges.
How to use it
- Paste the text into the box.
- Choose how to trim lines, what to do with blank lines and tabs, and whether to normalise Unicode spaces.
- Check how many characters and lines were removed, then copy or download the result.
Frequently asked questions
Will it break my code indentation?
Not if you choose "Trailing spaces only": leading indentation is kept, and collapsing spaces only affects runs after the indentation.
What is a zero-width space and why remove it?
U+200B is an invisible character often copied from web pages and chat apps. It makes identical-looking words compare as different and can break URLs, passwords and spreadsheet lookups.
How does tabs-to-spaces work?
Each tab is replaced by enough spaces to reach the next tab stop (every 2, 4 or 8 columns), the same way an editor displays it.
Does it change line endings?
Output uses Unix line endings (LF). Windows CRLF and old Mac CR endings in the input are recognised as line breaks.
Related tools
- Remove duplicate linesDelete repeated lines from a list, keeping the first or last occurrence, with case-sensitivity and trimming options.
- Find and replace textFind and replace text, as plain text or with regular expressions (capture groups, flags), with a count of replacements.
- Word counter and character counterCount words, characters (with and without spaces), sentences and paragraphs, estimate reading and speaking time, and see keyword density.
- Sort lines of textSort lines A to Z or Z to A, in natural numeric order, by length, reverse them, or shuffle them randomly.
- Case converterConvert text to UPPER, lower, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE.