Convert a list of lines to a comma separated list

Paste a column of lines and get one comma separated row. Nothing leaves your browser.

A column copied from a spreadsheet or a text file has one item per line, but many places want the items on a single row: an email list, a search box, a tag field or the list of values inside a SQL IN clause. This page opens with From set to new line and To set to comma, so each line becomes one item and the items are joined as a,b,c with no spaces. Choose Wrap each item in quotes to get 'a','b','c' or "a","b","c", which is the form most query lists and code arrays need. Blank lines are dropped by default, so a gap in your column does not leave two commas in a row, and spaces around each line are trimmed. Windows and Unix line endings both work. One honest limit: the page does not escape quote marks that are already inside an item, so check items that contain an apostrophe. The box opens with a short column of lines as a sample, so replace it with your own column.

How it works

  1. Paste your list
  2. Choose the delimiter it has now and the one you want
  3. Copy the converted list

Choosing the two delimiters

From is what separates the items in your text now, and To is what should separate them in the result. Both offer comma, new line, semicolon, tab, space and pipe, and a custom text of your own up to 50 characters. To also offers a comma followed by a space. A space means one single space character, a tab means the tab character, and a custom text is matched exactly, letter case included. If From is custom and the box is empty, the page asks you to type the separator and shows no result. A custom To may be empty, which joins the items with nothing between them.

Trim, empty items and quotes

The work runs in a fixed order. The text is split at the From delimiter. If Trim spaces around items is on, spaces and tabs at the start and end of each item are removed. If Remove empty items is on, items with nothing left are dropped. Then, if you chose quotes, each item is wrapped in single or double quote marks. Last, the items are joined with the To delimiter. Both toggles are on when the page opens. With Remove empty items off, two separators in a row keep an empty item, which shows as an empty line when To is new line. Quote marks that are already in your text are left as they are and are not escaped. A result that would be over 5,000,000 characters is not built; a message appears instead.

New lines and spaces as the source

When From is new line, Windows, old Mac and Unix line endings are each read as one break. A line break at the very end of the text leaves an empty last item, which Remove empty items drops. When From is space, every single space is a boundary, so two spaces in a row create an empty item between them. With Remove empty items on, that item is dropped and the words close up. The result uses a plain line break when To is new line.

What it does not do

This tool splits at a plain delimiter. It does not understand CSV quoting, so a comma inside a quoted field such as "Smith, John" still splits the field in two. It also does not sort or remove repeated items. To cut text into parts of a set length or at a delimiter into numbered parts, use the text splitter. To join wrapped paragraph lines, use the line break remover. The count under the result is the number of items after trimming and dropping empties. Everything runs in your browser, in this tab. The list is not uploaded, saved or put in the page address. Only your choices are remembered in this browser.

Frequently asked questions

How do I get a comma and a space between items?

Set To to Comma and space. The result then reads a, b, c instead of a,b,c. Everything else, such as trimming and quotes, works the same.

Can I make a list for a SQL IN clause?

Choose Single under Wrap each item in quotes and keep To on comma. Lines apple and pear become 'apple','pear'. Add the parentheses yourself, and check any item that holds an apostrophe, because quote marks already in the text are not escaped.

How do I turn a comma separated list into one item per line?

Leave From on comma and To on new line, paste the list, and copy the result. Trim and Remove empty items are on, so apple, banana,, cherry gives three lines: apple, banana and cherry.

How do I put quotes around each item?

Choose Single or Double under Wrap each item in quotes. The quotes are added after trimming, so " banana " becomes "banana" with trimming on. Pick To comma to get a list like "a","b","c".

Why does a comma inside quotes still split my item?

The tool cuts at every comma. It does not read CSV quoting, so "Smith, John" becomes two items. Use the CSV tools for files with quoted fields, or pick a different delimiter such as a pipe.

What is the difference between comma and comma and space?

Comma joins the items as a,b,c. Comma and space joins them as a, b, c. Both are offered for To only, because Trim spaces around items already handles a space after the comma when reading.

Is my list uploaded?

No. The list is processed in your browser, in this tab, and no server receives it. Your delimiter and quote choices are saved in this browser, but the list is not, so closing the tab clears it.