How to Convert Line Breaks to Commas (Online, Excel, Word, Notepad++)
Need to turn a list, one item per line, into a single comma separated line? It is a common job for keywords, email addresses, product IDs and SQL queries. Here is how to do it in one click online, and in the apps you already use.
Online (fastest)
- Open our free Join Lines tool.
- Paste your list.
- Set Replace breaks with to Comma. Choose Custom for a different separator, such as
;or|. - Click Copy. Empty lines are skipped automatically, so you never get double commas.
In Excel
If each item is in its own cell (A1 to A10), join them with TEXTJOIN (Excel 2019 and Microsoft 365):
=TEXTJOIN(", ", TRUE, A1:A10)
If the whole list is inside one cell with line breaks, replace the breaks instead:
=SUBSTITUTE(A1, CHAR(10), ", ")
More options are in our guide on removing line breaks in Excel.
In Google Sheets
=TEXTJOIN(", ", TRUE, A1:A10)
For a single cell: =SUBSTITUTE(A1, CHAR(10), ", ").
In Microsoft Word
- Press Ctrl+H.
- Find what:
^p. Replace with:,(comma and space). - Click Replace All, then delete the extra comma at the end.
In Notepad++ or VS Code
- Press Ctrl+H and turn on Regular expression mode.
- Find:
\r?\n. Replace with:, - Click Replace All.
Bonus: wrap each item in quotes
For an SQL IN (...) list, use a custom separator of ', ' in our Join Lines tool, then add a quote at the start and end: 'apple', 'banana', 'cherry'.
Frequently asked questions
How do I convert commas back to line breaks?
In Word, replace ", " with ^p. In Notepad++, use regular expression mode and replace ",\s*" with \n. In Excel, =SUBSTITUTE(A1, ", ", CHAR(10)) and turn on Wrap Text.
How do I remove duplicates before joining?
In our Remove Empty Lines tool, tick "Remove duplicate lines", copy the result and then join it with commas.
Is there a limit to how many lines I can join?
No fixed limit. The tool runs in your browser and handles lists with many thousands of lines.