Remove Extra Spaces and Blank Lines
Clean up text that has been copied between apps: repeated spaces collapse to one, trailing whitespace disappears, and blank lines are removed.
Four levels of cleaning
"Extra whitespace" covers several different problems, and fixing all of them at once is not always what you want. That is why this page offers four modes rather than a single button.
| Mode | What it changes |
|---|---|
| Clean everything | Collapses runs of spaces and tabs, strips trailing whitespace, removes every blank line |
| Trim line ends only | Removes leading and trailing whitespace from each line, leaves the rest untouched |
| Collapse blank lines | Turns runs of two or more blank lines into exactly one, keeping paragraph breaks |
| Delete all blank lines | Removes every empty line, producing a solid block |
Why indentation is preserved by default
Most whitespace cleaners collapse all repeated spaces, including the ones at the start of a line. For prose that is fine. For anything indentation-sensitive — Python, YAML, Markdown lists, nested JSON — it is destructive, and the damage is not obvious until the file fails to parse.
DevClean therefore separates leading whitespace from the rest of the line. The indentation stays exactly as it was; only the spaces inside the line get collapsed. If you genuinely want a flat, fully-collapsed result, switch off Preserve indentation.
Where the mess comes from
Text picks up junk whitespace whenever it crosses an application boundary. Copying from a PDF inserts spaces where the layout engine had letter-spacing. Pasting from Word brings non-breaking spaces that look identical to normal ones but do not match a plain space in search-and-replace. Exporting from a spreadsheet pads cells to align columns. Wrapping an email at 72 characters leaves trailing spaces at every break. None of these are visible, and all of them break exact comparisons later on.
Tip: if you are about to compare two lists, deduplicate them, or import them into a database, run this tool first. A large share of "these should have matched" problems are one invisible trailing space.
Collapsing versus deleting blank lines
The distinction matters more than it looks. In prose, blank lines are paragraph boundaries: deleting them all fuses your paragraphs into a wall of text, whereas collapsing runs of them to one keeps the structure while removing the gaps. In a list of values the opposite is true — every blank line is noise and you want them all gone. Pick the mode that matches what the blank lines actually mean in your document.
Frequently asked questions
Will this break my code indentation?
Not with Preserve indentation switched on, which is the default. Leading spaces and tabs are left byte-for-byte intact; only whitespace inside the line is collapsed. Switch the option off if you deliberately want a flat result.
What is the difference between collapsing and deleting blank lines?
Collapsing turns runs of two or more blank lines into exactly one, so paragraph breaks survive. Deleting removes every blank line, which is what you want for a list of values but not for prose.
Does it handle tabs as well as spaces?
Yes. Runs of spaces and tabs are both collapsed. If you specifically want to convert between the two rather than collapse them, use the tabs-to-spaces converter.
Does it remove non-breaking spaces pasted from Word?
Trailing non-breaking spaces are stripped along with other trailing whitespace. For non-breaking spaces in the middle of a line, run the text through the HTML entity tools first, which convert to a regular space.