# How to replace line breaks with commas in Excel

Use =SUBSTITUTE(A2,CHAR(10),", "). CHAR(10) is the line break inside a cell.

**Excel:** `=SUBSTITUTE(A2,CHAR(10),", ")` (Excel 2024 and Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Items (one per line) | Comma list |
| chair desk lamp |  |
| monitor |  |
| dock cable mouse keyboard |  |
| desk lamp |  |
| stapler tape |  |

Formula in B2, filled to B6: `=SUBSTITUTE(A2,CHAR(10),", ")`

Result: chair, desk, lamp; monitor; dock, cable, mouse, keyboard; desk, lamp; stapler, tape

## How it works

Each line break is the character CHAR(10). SUBSTITUTE swaps every one of them for a comma and a space, so the lines become one list that is easy to paste into an email or another system.

## Other ways

- `=TEXTJOIN(", ",TRUE,TEXTSPLIT(A2,CHAR(10)))`: Excel 365: split at the line breaks and join with commas. TRUE skips empty lines, which SUBSTITUTE would turn into ", ,".

## Common mistakes

- An empty line gives a double comma with SUBSTITUTE. Use the TEXTJOIN version, or TRIM the text first.
- Some exports use CHAR(13) and CHAR(10) together. Replace `CHAR(13)&CHAR(10)` first, or you get stray invisible characters.

## Questions

**How do I go the other way, from commas to line breaks?**

Swap them: `=SUBSTITUTE(A2,", ",CHAR(10))`, and turn on Wrap Text.

**Does Google Sheets use the same character?**

Yes, CHAR(10).

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/replace-line-breaks-with-commas
