Skip to content
SheetFluent

How to remove line breaks in Excel

SheetFluent team · · 6 min read

To remove line breaks in Excel, select the cells, press Ctrl+H, click in the Find what box and press Ctrl+J, type a space in Replace with, and click Replace All. To do it with a formula, use =TRIM(SUBSTITUTE(A2,CHAR(10)," ")). In words: swap every line break in A2 for a space, then remove any spaces left doubled up. Both work in Excel and Google Sheets.

What a line break is in a cell

A line break is a hidden character that starts a new line inside one cell. People type one with Alt+Enter on Windows, and they arrive in bulk when you paste addresses, product descriptions or form answers from a website or another system.

Excel stores the line break as character number 10, called a line feed. That is why formulas refer to it as CHAR(10). Some exports also add character 13, a carriage return, just before each line feed. You can't see either one, but they stop lookups from matching and make rows tall.

If a cell shows its text on one line but the formula bar shows several lines, the line breaks are there and Wrap Text is off. If a cell is tall and the text is stacked, Wrap Text is on.

Method 1: Find and Replace (no formula)

Use this when you want to change the cells themselves and don't need to keep the original text.

1. Select the cells or the column you want to clean. If you select one cell, Excel searches the whole sheet.

2. Press Ctrl+H to open Find and Replace.

3. Click in the Find what box and press Ctrl+J. The box looks empty, or shows a small blinking dot. That is the line break character, and it is meant to look like that.

4. Click in Replace with and type one space. If you want the parts joined with a comma instead, type a comma and a space.

5. Click Replace All, then turn Wrap Text off on the Home tab so the rows shrink back.

If Excel says it found nothing, click in Find what, press Backspace a few times to clear it, and press Ctrl+J once more. Pressing it twice searches for two line breaks in a row, which is a common reason the replace finds nothing.

Method 2: SUBSTITUTE with CHAR(10)

A formula keeps the original text in place and puts a clean copy next to it. That is handy when the data is refreshed often, or when you want to check the result before replacing anything.

SUBSTITUTE swaps one piece of text for another. SUBSTITUTE(A2,CHAR(10)," ") reads as "in A2, replace each line break with a space". Wrap it in TRIM, which removes spaces at the start and end and turns runs of spaces into one. Without TRIM, a line that ended with a space leaves two spaces in the middle.

If your data came from a system that adds carriage returns too, remove those first. Nest a second SUBSTITUTE that swaps CHAR(13) for nothing, then swap CHAR(10) for a space.

Once the clean column looks right, you can copy it and use Paste Special, Values to replace the original text, then delete the formula column.

=TRIM(SUBSTITUTE(A2,CHAR(10)," "))
=TRIM(SUBSTITUTE(SUBSTITUTE(A2,CHAR(13),""),CHAR(10)," "))

See also: Swap characters with SUBSTITUTE

Method 3: CLEAN, and when not to use it

CLEAN removes the first 32 characters in the character set, which are the non-printing ones. Line feeds and carriage returns are among them, so =CLEAN(A2) removes line breaks in one short formula.

The catch is that CLEAN removes the break and puts nothing in its place. "12 Oak Rd" on one line and "Austin" on the next becomes "12 Oak RdAustin". Use CLEAN when the breaks sit at the end of the text or between parts that already have spaces. Use SUBSTITUTE when you need a space or comma where each break was.

=CLEAN(A2)

Non-breaking spaces: CHAR(160)

Text copied from web pages often carries a non-breaking space, character 160. It looks exactly like a normal space, but TRIM and CLEAN both leave it alone. If TRIM seems to do nothing, this is usually why.

Swap it for a normal space first, then TRIM: =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). You can combine this with the line break fix by nesting one SUBSTITUTE inside the other.

To check what a stray character is, =CODE(LEFT(A2,1)) shows the number of the first character in A2. A result of 160 means a non-breaking space.

=TRIM(SUBSTITUTE(SUBSTITUTE(A2,CHAR(160)," "),CHAR(10)," "))

See also: How to remove duplicates in Excel

In Google Sheets

The formulas above work in Google Sheets as written: SUBSTITUTE, CHAR, CLEAN and TRIM all behave the same way.

Find and replace in Sheets does not accept Ctrl+J. Instead, open Edit, Find and replace, tick Search using regular expressions, type \n in Find, and type a space in Replace with. Then click Replace all.

Sheets also has a Trim whitespace option under Data, Data cleanup. It tidies spaces but does not remove line breaks, so use it after the replace.

Add line breaks back in, the right way

Sometimes you want the opposite: one item per line inside a cell, such as an address label. =A2&CHAR(10)&B2 joins two cells with a line break between them. Turn on Wrap Text for that cell, or the break won't show.

TEXTJOIN does the same for a whole range: =TEXTJOIN(CHAR(10),TRUE,A2:C2) stacks the parts of an address on separate lines and skips any blank part.

Keep a clean copy without line breaks for lookups, sorting and counting, and use the stacked version only where people need to read it.

=A2&CHAR(10)&B2
=TEXTJOIN(CHAR(10),TRUE,A2:C2)

See also: Join text with &, CONCAT and TEXTJOIN

Why the practice below starts after step one

Our practice sheet can't hold a real line break, so the exercise starts where Method 1 leaves you. The breaks have been replaced with spaces, and some addresses now have doubled spaces or a space at the start. TRIM finishes the job, and it is the same function you'd wrap around SUBSTITUTE in Method 2.

Try it here

Type the formula into the answer cell, then press Enter or Check.

The line breaks in these addresses were replaced with spaces, leaving doubles. In B2, type =TRIM(A2). It will be filled down to B6.

AB
1AddressClean
24 Oak Rd Austin (answer cell)
317 Elm St Salem
4 9 Lake Ave Troy
522 Pine Ct Reno
65 Bay Dr Dover
Start practicing

Questions people ask

What is CHAR(10) in Excel?

It is the line break character, a line feed. CHAR(10) lets a formula find or add line breaks, for example =SUBSTITUTE(A2,CHAR(10)," ").

Why does Find and Replace say it can't find anything?

The Find what box may hold two line breaks, or an old search. Clear it with Backspace, press Ctrl+J once, and try again. Also check you selected the right cells.

Does TRIM remove line breaks?

No. TRIM removes extra spaces only. Use SUBSTITUTE with CHAR(10) or CLEAN for the line breaks, then TRIM to tidy the spaces left behind.

How do I replace line breaks with a comma?

Use a comma and a space as the replacement: =SUBSTITUTE(A2,CHAR(10),", "). In Find and Replace, type the comma and space in Replace with.

Keep practicing

Practice this in the full lesson: Remove extra spaces with TRIM