← All how-to recipes

How to remove line breaks from a cell

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Replace the newline characters inside a cell with spaces (or nothing) to flatten multi-line text.

The formula

AppFormulaNotes
Excel (desktop)=SUBSTITUTE(A2,CHAR(10)," ")CHAR(10) is the line-feed; use CHAR(13) too for Windows carriage returns.
Google Sheets=SUBSTITUTE(A2,CHAR(10)," ")Identical.
LibreOffice Calc=SUBSTITUTE(A2,CHAR(10)," ")Identical.

How it works

CHAR(10) is the line-break character. SUBSTITUTE swaps every line break for a space, turning two-line text into one line: 'line1\nline2' becomes 'line1 line2'. Replace " " with "" to delete the breaks entirely.

Verified, not just documented

We ran =SUBSTITUTE(A2,CHAR(10)," ") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned line1 line2 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned line1 line2 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

SUBSTITUTE · CHAR — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons