Remove Extra Spaces and Line Breaks from Text

Paste messy text and choose what to clean. Spaces, blank lines and hidden characters are fixed instantly in your browser.

Runs in your browser — nothing you enter is uploaded

Remove Extra Spaces

All fields are required unless marked “optional”.

Tip: press Ctrl+Enter (Cmd+Enter on Mac) inside a text box to run.

Your result will appear hereStart typing and it updates instantly.

Formula

  • characters removed = characters before − characters after
  • Repeated spaces and tabs become a single space
  • Zero-width characters (U+200B–U+200D, U+2060, U+FEFF) are deleted

Each cleaning step is applied in turn, and the difference in length is reported.

Worked examples

Tidy a pasted paragraph

Your text
This text has extra spaces. It also has blank lines and a stray tab.
Collapse repeated spaces and tabs into one
Yes
Trim spaces at the start and end of every line
Yes
Blank lines
Allow at most one blank line in a row
Turn non-breaking and special spaces into normal spaces
Yes
Remove invisible zero-width characters
Yes
Join all lines into one paragraph
No

Characters removed

16

Characters before: 85

Characters after: 69

Lines after: 3

This text has extra spaces.

It also has blank lines and a stray tab.

Un-wrap text copied from a PDF

Your text
Lines copied from a PDF are broken in the middle of every sentence.
Collapse repeated spaces and tabs into one
Yes
Trim spaces at the start and end of every line
Yes
Blank lines
Remove all blank lines
Turn non-breaking and special spaces into normal spaces
Yes
Remove invisible zero-width characters
Yes
Join all lines into one paragraph
Yes

Characters removed

0

Characters before: 67

Characters after: 67

Lines after: 1

Lines copied from a PDF are broken in the middle of every sentence.

How it works

Text copied from PDFs, web pages, emails and chat apps often carries more whitespace than you can see: double spaces after full stops, tabs, blank lines between every paragraph, non-breaking spaces that look like normal ones and zero-width characters that are completely invisible. Each option here targets one of those, and you can combine them. The summary shows how many characters were removed, which is a quick way to confirm that something invisible was there.

Collapsing turns any run of spaces and tabs into a single space; trimming removes spaces at both ends of every line. Blank lines can be kept, limited to one in a row, or removed entirely. Joining lines turns a hard-wrapped block of text (for example, copied from a PDF) into one flowing paragraph by replacing each line break with a space. Line endings are normalised, so text from Windows and Mac behaves the same.

Line breaks inside quotes or code are treated like any other, so do not use joining on code or poetry. For counting what remains use the Word Counter, for changing particular words use Find and Replace Text, for removing repeated lines use Remove Duplicate Lines, and for changing capitalisation use the Case Converter.

Assumptions and limits

  • Only spaces, tabs, line breaks and the listed invisible characters are changed; words and punctuation are untouched.
  • Joining lines also removes blank lines, because they would otherwise become extra spaces.
  • Text above about 2 million characters is not accepted.

Common questions

How do I remove line breaks from text?
Turn on “Join all lines into one paragraph”. Every line break becomes a single space and blank lines are dropped.
Why does my text still look spaced out?
It may contain non-breaking or zero-width characters. Keep the special-spaces and zero-width options on to normalise them.
Will it change my words or punctuation?
No. Only whitespace and the listed invisible characters are touched.
Does it work on code?
It works on any text, but trimming and collapsing change indentation, so avoid it on code or other text where spacing matters.