Guides

How to Convert Line Breaks to Commas (Online, Excel, Word, Notepad++)

By Ali Ahmad ·

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.

Beforeapple banana cherry
Afterapple, banana, cherry

Online (fastest)

  1. Open our free Join Lines tool.
  2. Paste your list.
  3. Set Replace breaks with to Comma. Choose Custom for a different separator, such as ; or |.
  4. 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

  1. Press Ctrl+H.
  2. Find what: ^p. Replace with: , (comma and space).
  3. Click Replace All, then delete the extra comma at the end.

In Notepad++ or VS Code

  1. Press Ctrl+H and turn on Regular expression mode.
  2. Find: \r?\n. Replace with: ,
  3. 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.

Written by Ali Ahmad. We build free, private text tools that run in your browser.