← Back to the tool

How to Remove Extra Spaces in Notepad++

Notepad++ has no single-click "remove extra spaces" command, but Find and Replace's Regular expression mode covers double spaces, blank lines, and line-start/end spaces with one search pattern each. They're ready to paste in, plus the one setting that makes every pattern below do nothing if you skip it.

Turn on Regular expression search

Open Find and Replace and look at the Search Mode section near the bottom of the dialog. It defaults to Normal. Every pattern on this page needs Regular expression selected instead, or the pattern is matched as plain text and finds nothing. This is the single most common reason these steps appear not to work.

Ctrl+H → Search Mode → Regular expression

Skip the manual steps. Clean your text instantly, right here.

Clean it instantly with the free tool

Replace two or more spaces with one

Find what: [ ]{2,} → Replace with: (one space) → Replace All

Remove blank lines

Find what: ^[ \t]*\r?\n → Replace with: (nothing) → Replace All

\r?\n matches both Windows-style and Unix-style line endings, so this pattern works regardless of where the file came from.

Trim spaces at the start or end of every line

Find what: ^[ \t]+|[ \t]+$ → Replace with: (nothing) → Replace All

Running Replace All a second time after it reports 0 replacements is always safe. It means the job is already done. For a one-off cleanup where opening Notepad++ and building a pattern is more setup than the job is worth, the free tool does all three of the above in one paste.

Clean my text now