How to remove line breaks from cells in Excel
Formula (Excel and Google Sheets)
=TRIM(SUBSTITUTE(A2,CHAR(10)," "))Replace CHAR(10), the line break, with a space and trim: =TRIM(SUBSTITUTE(A2,CHAR(10)," ")).
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
A line break inside a cell is character 10. SUBSTITUTE replaces each one with a space so the words stay apart, and TRIM collapses the double space left by the empty line in row 5.
=TRIM(SUBSTITUTE(A2,CHAR(10)," "))Result"1420 Lake St Minneapolis, MN 55401"
A2"1420 Lake St Minneapolis, MN 55401"The value in A2.
CHAR(10)" "CHAR: Character for a code number.- number
10
- number
SUBSTITUTE(A2,CHAR(10)," ")"1420 Lake St Minneapolis, MN 55401"SUBSTITUTE: Replaces matching text.- text
A2"1420 Lake St Minneapolis, MN 55401" - old_text
CHAR(10)" " - new_text
" "
- text
TRIM(SUBSTITUTE(A2,CHAR(10)," "))"1420 Lake St Minneapolis, MN 55401"TRIM: Removes extra spaces, leaving single spaces between words.- text
SUBSTITUTE(A2,CHAR(10)," ")"1420 Lake St Minneapolis, MN 55401"
- text
In Google Sheets
The same formula works in Google Sheets: =TRIM(SUBSTITUTE(A2,CHAR(10)," ")). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =CLEAN(A2) | 1420 Lake StMinneapolis, MN 55401, 88 Oak AveSaint Paul, MN55102, 7 Elm Ct, Madison, WI 53703…Different result | CLEAN removes line breaks and other control characters, but replaces them with nothing. Words are joined: "1420 Lake StMinneapolis, MN 55401". |
Common mistakes
- Text from Windows files can also have CHAR(13) before each break. Remove both:
=TRIM(SUBSTITUTE(SUBSTITUTE(A2,CHAR(13),""),CHAR(10)," ")). - To do it in place, use Find and Replace and press Ctrl+J in the Find box to enter a line break.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Remove line breaks from cells
B2, replace each line break with a space so the address is on one line, and fill down to B6.Questions
How do I replace the line breaks with commas?
Use =SUBSTITUTE(A2,CHAR(10),", ").
Does this work in Google Sheets?
Yes. Google Sheets uses CHAR(10) for line breaks too.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.