How-to recipes · Cleaning data
How to remove line breaks in Excel
Replace line breaks inside cells with a comma or space using SUBSTITUTE and CHAR(10), CLEAN, or Find & Replace with Ctrl+J, and split lines into columns.
Addresses copied from an online form, product descriptions exported from a shop system, or comments typed with Alt+Enter often contain line breaks inside the cell. They look tidy when wrap text is on, but they cause trouble elsewhere: a CSV export breaks into extra rows, a mail merge prints the address on one squashed line, lookups fail because the text contains a hidden character. This recipe shows how to replace line breaks with a separator, remove them completely, or use them to split the text into columns.
The example data
Three addresses in A2:A4, each written over two or three lines inside one cell. The line break character in Excel for Windows is character 10, called a line feed, which you can produce in a formula with CHAR(10).
Replace line breaks with a comma (every version)
SUBSTITUTE replaces every occurrence of one text with another. Give it the line feed as the text to find:
| A | B | C | |
|---|---|---|---|
| 1 | Address | ||
| 2 | 12 Harbour St Piraeus 185 37 | 12 Harbour St, Piraeus, 185 37 | |
| 3 | Unit 4 Mill Road Leeds LS1 2AB | ||
| 4 | Main Square 7 Graz |
Each line break becomes a comma and a space, so the address fits on one line.
Result: 12 Harbour St, Piraeus, 185 37
Use " " as the replacement to join the lines with spaces, or "" to remove the breaks without any separator. Copy the formula down for the other rows, or in Microsoft 365 write it once for the whole range: =SUBSTITUTE(A2:A4,CHAR(10),", ").
Text from other systems: CHAR(13)
Files that come from Windows applications sometimes use two characters per line break: a carriage return, character 13, followed by the line feed. Replacing only CHAR(10) then leaves an invisible character 13 behind. Remove both:
=SUBSTITUTE(SUBSTITUTE(A2,CHAR(13),""),CHAR(10),", ")If you are unsure what a cell contains, compare =LEN(A2) before and after; any difference that is not explained by the visible characters is a hidden character. CLEAN removes characters 0 to 31, including both line-break characters, but it replaces them with nothing, which glues words together. =TRIM(CLEAN(A2)) is fine when the lines end with a space; otherwise SUBSTITUTE gives a better result.
Without formulas: Find & Replace with Ctrl+J
- Select the cells (or a whole column).
- Press Ctrl+H to open Find & Replace.
- Click in the Find what box and press Ctrl+J. Nothing seems to appear, but a line feed has been entered; you may see a tiny blinking dot.
- In Replace with type a comma and a space, or a single space.
- Click Replace All.
This changes the cells in place, so it is fast for a one-off clean-up. After replacing, switch off Wrap Text (Home > Wrap Text) so the rows shrink back to normal height.
Microsoft 365: split the lines into columns
Sometimes the line breaks are useful: each line is a separate field (street, city, postcode). TEXTSPLIT splits at the line feed and spills the parts into neighbouring cells:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Address | ||||
| 2 | 12 Harbour St Piraeus 185 37 | ||||
| 3 | Unit 4 Mill Road Leeds LS1 2AB | Unit 4 | Mill Road | Leeds LS1 2AB | |
| 4 | Main Square 7 Graz |
The three lines of the address land in C3, D3 and E3.
Use TEXTSPLIT(A3,,CHAR(10)) (delimiter in the third argument) to split into rows instead. In Excel 2016 and 2019, use Data > Text to Columns > Delimited, tick Other and press Ctrl+J in the box next to it.
Adding line breaks with a formula
The reverse is useful for labels and address blocks: join parts with CHAR(10) and turn on Wrap Text. =A2&CHAR(10)&B2&CHAR(10)&C2 stacks three cells, and TEXTJOIN does it while skipping empty parts: =TEXTJOIN(CHAR(10),TRUE,A2:C2). Without Wrap Text the cell shows everything on one line, so always switch it on.
Pitfalls
- Nothing seems to happen. If SUBSTITUTE with CHAR(10) changes nothing, the text may use CHAR(13) only (common in files from old Mac systems). Try the CHAR(13) version.
- Double separators. Empty lines (two breaks in a row) become
, ,. Run SUBSTITUTE for the double break first, or clean up with another SUBSTITUTE. - Row heights stay tall. After removing breaks, select the rows and double-click a row border to autofit.
- CSV exports. Line breaks inside cells are kept in quotes in a correct CSV, but many tools that read CSV files still break the row. Clean them before exporting.