Excel guide · 4 min read
How to remove line breaks in Excel cells
=SUBSTITUTE(B2,CHAR(10),", ") to swap each line break for a comma and space, or wrap it in TRIM with a space instead: =TRIM(SUBSTITUTE(B2,CHAR(10)," ")). Without a formula, press Ctrl+H, press Ctrl+J in Find what, type a space in Replace with and click Replace All. If odd gaps remain, the data also has CHAR(13) carriage returns.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | |
|---|---|---|---|
| 1 | Customer | Address | Delivery note |
| 2 | Nadia Rahman | 14 Alder Road Leeds LS6 2AB | Leave with neighbour |
| 3 | Tom Becker | Flat 3 22 Mill Lane Bristol BS1 4DJ | Gate code 4471 Call on arrival |
| 4 | Priya Shah | Unit 7 Park Way Slough SL1 3QX | Leave at side door Ring twice |
| 5 | Grace Okafor | 9 Quay Street, Cardiff CF10 1EA | Signature needed |
Download this sheet as an Excel practice file (.xlsx)
Swap CHAR(10) for a separator
A line break inside a cell, the kind you get from Alt+Enter, a web form or a CRM export, is the character CHAR(10). SUBSTITUTE finds every one of them and replaces it with whatever you choose. For addresses, a comma and space reads naturally and keeps the parts apart.
Replacing with nothing ("") is rarely what you want: the lines run together, so "Leeds" and "LS6 2AB" become "LeedsLS6 2AB". Always replace with a space or a separator.
Result: 14 Alder Road, Leeds, LS6 2AB
14 Alder Road, Leeds, LS6 2AB, on one line, ready for a mail merge or a single-line address field.
Replace with a space, then TRIM
Real data has stray spaces next to the breaks and empty lines between paragraphs. Priya's address has a space before its first break, and her delivery note has a blank line in the middle. Replacing each break with a space then leaves double spaces.
TRIM fixes that: it removes spaces at the start and end and squeezes runs of spaces down to one. Note that TRIM on its own does not remove line breaks, only spaces, so you need SUBSTITUTE first.
Result: Leave at side door Ring twice
Leave at side door Ring twice, with the blank line and the extra spaces gone. On B4 it gives Unit 7 Park Way Slough SL1 3QX.
CHAR(13): the break that stays behind
Text from some Windows systems and databases ends each line with two characters: a carriage return, CHAR(13), and then the line feed, CHAR(10). Remove only CHAR(10) and the carriage returns stay in the cell. They are invisible or show as a small box, but they break lookups, make LEN too long, and turn up as strange gaps when you paste the text elsewhere.
Tom's address came from such an export. Remove CHAR(13) first, then swap CHAR(10) for the separator. If you are not sure which kind you have, this version is safe on both.
Result: Flat 3, 22 Mill Lane, Bristol, BS1 4DJ
Flat 3, 22 Mill Lane, Bristol, BS1 4DJ. LEN(B3) is 38, but only 35 once CHAR(13) is removed: the 3 extra characters are carriage returns.
CLEAN: removes breaks, but glues the words
CLEAN deletes the non-printing characters 0 to 31, which includes both CHAR(10) and CHAR(13). It is the quickest way to get rid of every kind of break and other control characters from old systems. Its catch is that it deletes them with no space in their place.
The fix is to combine the tools: SUBSTITUTE turns the line feeds into spaces, CLEAN removes the carriage returns and any other control characters, and TRIM tidies the spacing. This is the formula to pick for messy exports when a single-line result is what you need.
Result: Flat 3 22 Mill Lane Bristol BS1 4DJ
Flat 3 22 Mill Lane Bristol BS1 4DJ. Plain =CLEAN(B2) gives 14 Alder RoadLeedsLS6 2AB, with the lines stuck together.
Find and Replace with Ctrl+J (no formula)
To clean the cells in place without a helper column, use Find and Replace. Ctrl+J types a line feed into the Find what box. The box looks empty afterwards (you may see a tiny blinking dot), but it holds the break. This only finds CHAR(10); if your data also has CHAR(13), use the formula in the CHAR(13) section instead.
- Select the column, for example B2:C5. If you select a single cell, Excel searches the whole sheet.
- Press Ctrl+H to open Find and Replace.
- Click in Find what and press Ctrl+J once.
- In Replace with, type a space (or a comma and a space).
- Click Replace All. Then turn off Home > Wrap Text if you no longer need it, and double-click a row border to fit the height.
Find the cells that still have breaks
Before and after cleaning, count the cells that contain a line break. FIND returns a position when it finds CHAR(10) and an error when it does not, so ISNUMBER turns that into TRUE or FALSE, and SUMPRODUCT counts the TRUEs.
To count the lines in one cell, compare lengths: =LEN(B2)-LEN(SUBSTITUTE(B2,CHAR(10),""))+1 gives 3 for Nadia's address. To keep only the first line, use =TEXTBEFORE(B2,CHAR(10)) in Excel 365.
Result: 5
5 cells in B2:C5 contain at least one line break. Grace's address and the notes on rows 2 and 5 have none.
Common mistakes
Replacing the break with nothing
The lines merge into one word, like RoadLeeds. Replace with a space or ", ", then TRIM.
Expecting TRIM to remove line breaks
TRIM only handles spaces. Use SUBSTITUTE with CHAR(10) or CLEAN, then TRIM the result.
Removing CHAR(10) but not CHAR(13)
Text from Windows exports keeps its carriage returns, so lookups still fail. Use SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),""),CHAR(10),", ") or TRIM(CLEAN(...)).
Deleting the original column after using a formula
The formulas then return #REF!. Copy the results, Paste Special > Values, and only then delete the source.
FAQ
How do I remove line breaks in Excel?
Use =SUBSTITUTE(A2,CHAR(10)," ") in a formula, or press Ctrl+H, press Ctrl+J in Find what, type a space in Replace with and click Replace All.
Why does Ctrl+J not find anything?
Either you pressed Ctrl+J more than once, so the box now holds two breaks, or the cells use CHAR(13) carriage returns. Close the dialog, reopen it to clear the box, press Ctrl+J once, or use a formula with CHAR(13).
What is the difference between CHAR(10) and CHAR(13)?
CHAR(10) is a line feed, which Excel uses for line breaks inside a cell. CHAR(13) is a carriage return, which some systems put before each line feed. Remove both when cleaning exported text.
Does CLEAN remove line breaks?
Yes, CLEAN removes CHAR(10), CHAR(13) and the other non-printing characters 0 to 31. It leaves no space in their place, so use TRIM(CLEAN(SUBSTITUTE(A2,CHAR(10)," "))) to keep words apart.
How do I replace line breaks with a comma?
=SUBSTITUTE(A2,CHAR(10),", "). Wrap it as SUBSTITUTE(SUBSTITUTE(A2,CHAR(13),""),CHAR(10),", ") if the text came from a Windows export.
Functions used
SUBSTITUTEReplaces textTRIMRemoves extra spacesLENLength of textFINDPosition of text (case-sensitive)ISNUMBERIs it a number?SUMPRODUCTMultiply then addTEXTBEFOREText before a delimiter
Related guides
- Combine cells with a line break in Excel
- How to remove spaces in Excel
- How to remove characters from a cell in Excel
- How to replace text in Excel with a formula
- How to count characters in a cell in Excel
- Excel date format not changing? Why, and how to fix it
Updated