Free online text tool

Replace New Lines with Commas

Replace New Lines with Commas turns a list with one item per line into a single comma separated line. Paste your text, click the button and copy the result. It is free and runs in your browser.

Replace New Lines with Commas

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Replace New Lines with Commas Example

Before
apple
banana
cherry
After
apple,banana,cherry

Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.

Suggest a New ToolProvide Feedback on This Tool

What does Replace New Lines with Commas do?

This tool replaces every new line in your text with a comma. A list with one item on each line becomes one line of comma separated items, ready to paste into a spreadsheet, a database query, a form or a program.

Empty lines are skipped by default, so you do not get a row of commas in a row, and spaces around each line are trimmed. You can add a space after each comma if you want a list that is easy to read, such as apple, banana, cherry.

Use it for email lists, tags, keywords, product codes, ID numbers and anything else you copied as a column.

Replace new lines with commas examples

Unless an option is named, no space is added after the comma, empty lines are skipped and spaces around each line are trimmed.

SettingBeforeAfter
Simple list
apple
banana
cherry
apple,banana,cherry
Numbers
1
2
3
4
1,2,3,4
Space after each comma
apple
banana
cherry
apple, banana, cherry
Empty lines skipped
red

green

blue
red,green,blue
Empty lines kept
red

green

blue
red,,green,,blue
Spaces trimmed
  one  
  two  
one,two
Spaces not trimmed
  one  
  two  
  one  ,  two  

How to replace new lines with commas

  1. 1
    Add your text
    Type or paste your list into the box, one item on each line, or import a text file.
  2. 2
    Choose your options
    Tick Add a space after each comma if you want a readable list. Leave Skip empty lines ticked to avoid double commas.
  3. 3
    Click Replace New Lines
    Each new line becomes a comma. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the result where you need it.

When to replace new lines with commas

Good for

Turning a column from a spreadsheet into a comma separated list, preparing values for a database query or a form, and joining tags, keywords, email addresses and ID numbers.

Check first

An item that already contains a comma is not wrapped in quotes, so it will look like two items. Quotes around each item are not added either. The result replaces your text, so use Undo if you need the original.

Other tools

To turn commas back into lines, try Convert Text with Commas To Lines. To remove line breaks without adding anything, try Remove Line Breaks. To drop empty lines first, try Remove Empty Lines.

Replace new lines with commas FAQ

What does the Replace New Lines with Commas tool do?

It converts text that has new lines into one line where the items are separated by commas.

How do I replace new lines with commas?

Paste your list, with one item on each line, then click Replace New Lines. Copy the result with the Copy button.

Is there a comma after the last item?

No. Commas are placed only between items, so the result does not end with a comma.

Can I add a space after each comma?

Yes. Tick Add a space after each comma and the result looks like apple, banana, cherry instead of apple,banana,cherry.

What happens to empty lines?

By default they are skipped, so you do not get two commas in a row. Untick Skip empty lines to keep them, and each one then leaves an empty item between two commas.

Are spaces at the start and end of a line removed?

Yes, by default, so an item written as " apple " becomes apple. Untick Trim spaces around each line to keep them.

Does it work with Windows and Mac line breaks?

Yes. Lines are split correctly whichever kind of line break your text has.

What if my text has no new lines?

The tool shows a message and leaves your text as it is.

Is this tool free and is my text private?

Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.

Looking for more text tools?

Browse Replace Tools

Last updated: 14 November 2026