Remove Whitespace & Empty Lines.
Trim lines, collapse repeated spaces, drop empty lines and strip invisible characters.
Runs in your browserAbout Remove Whitespace & Empty Lines
Text copied from PDFs, web pages, chat apps and spreadsheets is full of whitespace you did not ask for: double spaces between words, tabs at the start of lines, runs of blank lines and trailing spaces that break comparisons. This tool cleans all of that in one pass. By default it trims each line, collapses any run of spaces and tabs into a single space and removes empty lines, which is what most people need before pasting text into a form, a commit message or a database. If you want to keep paragraphs, turn off empty-line removal and keep single blank lines instead. Joining everything into one line is useful for turning a wrapped paragraph back into a sentence, and removing all whitespace helps with things like card numbers, IBANs or Base64 that were split across lines. The invisible-character option deletes zero-width spaces, joiners and byte-order marks and replaces non-breaking and other exotic spaces with a normal space; these characters are a frequent cause of "identical" strings that refuse to match. For example, a product code pasted from a website may contain a zero-width space that makes a lookup fail even though it looks right. Line endings are normalised to LF. The stats show how many characters and lines were removed, and nothing leaves your browser.
How to Use
- Paste the text you want to clean.
- Choose which kinds of whitespace to trim, collapse or remove.
- Copy the cleaned text.
Frequently Asked Questions
What counts as whitespace?
Spaces, tabs, line breaks, form feeds and the Unicode space characters such as the non-breaking space, thin space and ideographic space.
Can I keep paragraph breaks?
Yes. Switch off "Remove empty lines" and switch on "Keep single empty lines". Runs of blank lines shrink to one, so paragraphs stay separated.
What are zero-width characters?
Characters such as U+200B ZERO WIDTH SPACE or U+FEFF that take no room on screen. They sneak in from web pages and messengers and make equal-looking strings differ. Use the Unicode inspector to see them.
Does it change line endings?
Yes. Windows (CRLF) and old Mac (CR) line endings are converted to LF.
Related Tools
Reveal zero-width spaces, bidi overrides and odd spaces, and inspect every code point with its UTF-8 bytes.
Count characters, words, sentences, and more.
Sort lines alphabetically or naturally and remove duplicates.
Find and replace text with plain strings or regular expressions, capture groups and whole-word matching.
Convert text between case formats.
Escape and unescape strings for different formats.