TR

Home / Guides / How to Remove Extra Spaces and Line Breaks: A Text Cleanup Guide

How to Remove Extra Spaces and Line Breaks: A Text Cleanup Guide

Updated: October 13, 2026 · AracMerkezi

▶ Open Remove Extra Spaces and Line Breaks

When you copy text from a PDF, an email or a web page, the result often looks messy: double spaces between words, unwanted line breaks at the end of every line, stray blank lines and characters you cannot even see. In this guide we explain what causes extra spaces and line breaks, how to clean them up by hand in Word, Excel and Notepad++, and how to do it all in one step with a tool.

Where do the problems come from?

Why clean the text?

Messy text hurts readability, but the real trouble shows up elsewhere. In text entered into a database or a form, an extra space makes the same record look different. On the SEO side, hidden spaces cause errors when you build titles, meta descriptions and URLs. In fields with a character limit (SMS, tweets, meta descriptions), needless spaces use up valuable characters. Spell checking and word counting also work more accurately on clean text.

A simple example: in “Ankara İstanbul İzmir” there are 2 spaces between Ankara and İstanbul and 3 spaces between İstanbul and İzmir. The character count is 6 + 2 + 8 + 3 + 5 = 24. After cleaning, it becomes “Ankara İstanbul İzmir”, which is 6 + 1 + 8 + 1 + 5 = 21 characters, so you save 3 characters.

Manual methods in Microsoft Word

In Word, open the Ctrl + H (Find and Replace) window. Click the “More” button for additional options. The special character codes are: ^p paragraph mark, ^l manual line break, ^t tab, ^w any whitespace, ^s non-breaking space.

  1. Turning double spaces into a single space: Type two spaces in the Find box and one space in the Replace box, then click “Replace All” again and again. Keep going until the number of replacements is 0. Three or more spaces shrink step by step this way.
  2. Deleting blank lines: Type ^p^p in the Find box and ^p in the Replace box, and again repeat until no replacements are left.
  3. One pass with wildcards: Check the “Use wildcards” option. Type {2,} (a space followed by 2, in curly braces) in the Find box and put a single space in the Replace box. This reduces two or more spaces to a single space in one pass.
  4. Turning manual line breaks into paragraphs: Replace ^l with ^p.
  5. Turning tabs into spaces: Replace ^t with a space.
  6. Turning non-breaking spaces into normal spaces: Replace ^s with a space.

Caution: To remove the hard line break at the end of every line in text that came from a PDF while keeping the paragraphs, first replace the ^p^p between real paragraphs with a temporary marker (for example “@@”), then turn the remaining ^p marks into spaces, and finally convert the “@@” marker back to ^p. This keeps the paragraphs and removes the breaks inside them.

Cleaning in Excel

Three functions do the job for text in Excel cells (the Turkish-language Excel names are in parentheses):

TRIM does not remove the non-breaking space (character code 160). This is a common trap with data copied from the web. The complete formula is =TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," "))). In Turkish-language Excel the function names are KIRP, TEMİZ, YERİNEKOY and KARAKTER, and the argument separator is a semicolon. To turn line breaks into spaces, you can use =SUBSTITUTE(A1,CHAR(10)," "). To make the results permanent, copy the formula column and paste it with “Paste Special > Values”.

Notepad++ and regular expressions

In the Notepad++ Ctrl + H window, select Regular expression as the “Search Mode”. Useful examples (the replacement value is on the right):

One point to watch: the \s+ expression also counts line breaks as whitespace. If you replace \s+ with a single space across the whole text, all paragraphs merge into a single line. If you want to keep the paragraphs, use [ \t]+. Making a backup of the file before you start is a good habit.

Cleaning with a tool

Manual methods take time to learn and are prone to mistakes. You can paste your text into the Remove Extra Spaces and Line Breaks tool, tick the options you want, and clean it in seconds. Typical options are: reduce extra spaces to one, trim leading and trailing spaces, delete blank lines, and convert line breaks to spaces. Because the tool runs in your browser, the text is not sent to a server in normal use; still, be careful when pasting documents that contain confidential information into third-party sites.

Which method when?

SituationRecommended method
A short text, one-time cleanupTool
Fixing within a Word document while keeping the formattingWord Find and Replace
Hundreds of cells in ExcelTRIM, CLEAN, SUBSTITUTE formulas
Large text file, code, logsNotepad++ regular expression
A long article copied from a PDFTool first, then fix paragraphs by hand

Checks after cleaning

Tips for SEO and writing cleanup

Related tools

The Remove Extra Spaces and Line Breaks tool does the main cleanup job. Afterwards you can finalize the text with the Word Counter, Remove Duplicate Lines and Uppercase / Lowercase Converter tools.

Frequently asked questions

How do I remove double spaces in Word?

Open Find and Replace with Ctrl + H, replace two spaces with one space and repeat until no replacements are left; with the wildcard option, the expression ` {2,}` works in a single pass.

Why doesn’t TRIM remove invisible spaces in Excel?

A non-breaking space (character code 160) that comes from the web is not removed by the TRIM function; you first need to convert it to a normal space with SUBSTITUTE(A1,CHAR(160)," ").

How do I remove line breaks from text copied from a PDF?

Paste the text into a text cleanup tool and tick the options to convert line breaks to spaces and remove extra spaces; to keep the paragraphs, mark the paragraph breaks first.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.