Remove Extra Spaces & Line Breaks · Tutorial
How to clean up messy spacing in text copied from an email
4 min readbeginnerUpdated
You copied a message out of an email or web page to reuse it, and it's full of double spaces, odd indentation and big gaps between lines. Some of the spaces aren't even real spaces. This tutorial shows how to clean it up in one step and keep the paragraphs you want.
What you need
- The Remove Extra Spaces & Line Breaks
- The messy text (the Try it button loads an order confirmation)
Steps
Paste the text
Paste the copied text into the left box. The sample has double and triple spaces, trailing tabs, lines starting with spaces, and four blank lines between sentences. It also has a non-breaking space between "ships" and "tomorrow" that you can't see.
Keep the default fixes
With the default options, the right box shows the cleaned text immediately. Spaces are collapsed, lines are trimmed, blank lines are reduced to one, and the invisible space is replaced. The message says 25 characters were removed.
Thanks for your order! Your parcel ships tomorrow morning. Tracking: PW448210375GHRemove blank lines too if you need to
For a list, a form field or a spreadsheet cell, tick Remove all empty lines. Each line of text then follows directly after the previous one.
Copy the clean text
Press Copy and paste the text where you need it. If it still has a line break in the middle of each sentence, as text from PDFs often does, follow up with Remove Line Breaks.
Try it yourself
Opens the Remove Extra Spaces & Line Breaks with this tutorial's sample loaded.
Common mistakes
- Trimming code or poetry
- Trim each line removes indentation. Untick it when leading spaces carry meaning, as in code, YAML or verse.
- Removing all empty lines from prose
- Without blank lines, paragraphs run together. For normal text, collapsing blank lines is usually better than removing them.
- Expecting formatting to survive
- This tool works on plain text. Bold, links and fonts aren't kept when you paste text into it.
Next steps
Go back to the Remove Extra Spaces & Line Breaks, or keep going with one of these:
FAQ
Why didn't my search find a phrase that's clearly in the text?
Often because of a non-breaking or zero-width space in the middle. Cleaning the text first usually fixes the search.