Skip to content
Column to Comma,
More free tools

Convert a column to a comma separated list

Paste your rows. The list appears as you type. Add quotes, remove duplicates, sort, then copy.

Direction
Quick:
Options

Options

Your text never leaves your browser. Read how we handle data.

How to convert a column to a comma separated list

You have a column of values in Excel, Google Sheets or a SQL result. You need them in one line, with commas between them. This page does that. Paste the column into the left box and the list appears on the right. There is no button to press and nothing to install.

  1. Copy the cells. Select the column in your sheet and press Ctrl+C (Cmd+C on a Mac).
  2. Click the left box and paste. You can also tap Paste.
  3. Pick a separator and, if you need them, quotes.
  4. Press Copy, or hit Ctrl+Enter (Cmd+Enter on a Mac), and paste the list where you need it.

Worked example: build a SQL IN list

Say you have four customer IDs in a sheet and you want to look them up in a database. Paste these four rows:

1001
1002
1002
1004

Click SQL IN list, then tick Remove duplicates. You get this:

(1001, 1002, 1004)

Paste it after WHERE id IN and run the query. For text values such as names or codes, the quotes stay on, so you get ('AB-1', 'AB-2'). A name like O'Brien becomes 'O''Brien', which is the correct way to escape it in SQL.

One warning: Oracle allows at most 1,000 items inside one IN list. If your list is longer, split it into several lists.

Common settings

You wantSeparatorQuotesResult
Plain listCommaNonea,b,c
Readable listComma and spaceNonea, b, c
SQL IN listComma and spaceSingle, wrap in ( )('a', 'b', 'c')
JSON arrayComma and spaceDouble (JSON), wrap in [ ]["a", "b", "c"]
CSV rowCommaDouble"a","b","c"
Pipe listPipeNonea|b|c

Column to comma in Excel and Google Sheets

Both programs have a built-in way to join cells. In Excel and Sheets, =TEXTJOIN(",", TRUE, A1:A100) joins the range with commas and skips empty cells. It works well for a fixed range, but it cannot add quotes, drop duplicates or sort without extra formulas. This tool does all of that in one step, and you do not need to change your file.

The tool also accepts text copied from a database client, a CSV file, an email or a web page. It handles Windows, Mac and Linux line breaks.

What each option does

  • Trim spaces removes spaces and tabs around each value. Cells copied from a sheet often carry them.
  • Remove blank lines drops empty rows, so you never get a,,b.
  • Remove duplicates keeps the first copy of each value. Tick Ignore case for duplicates to treat Ab and ab as the same.
  • Sort orders values from A to Z or Z to A. Numbers inside text sort the natural way, so item2 comes before item10. The number options sort by value.
  • Letter case changes values to upper case, lower case or Title Case before duplicates are checked.
  • Before and after each item adds text around every value, such as <li> and </li>. The same pair of fields for the whole list adds text at the start and end.
  • Use only the first column keeps the first column when you copy several columns from Excel.
  • Do not quote numbers leaves 42 and 3.5 bare but quotes 007, so leading zeros survive.

Tips for clean results

If your values contain commas, such as "Smith, John", turn on double quotes so the next program reads each name as one value. Check the count under the output. It shows how many lines went in and how many items came out, so you can see that nothing was lost.

Convert a list back to a column

Switch to List to column to go the other way. Paste 'a', 'b', 'c' and you get three rows. The tool removes the quotes and brackets, and it keeps a comma that sits inside a quoted value. Leave Split on at Auto-detect to split on commas, semicolons, pipes or tabs.

When a comma separated list helps

  • Database queries. Fill an IN clause with IDs from a report instead of typing them one by one.
  • Email and marketing tools. Many forms ask for tags, addresses or keywords in one comma separated field.
  • Code. Turn a column of names into an array for Python, JavaScript or JSON.
  • Search and filters. Tools that filter by a list of SKUs or order numbers usually want one line.
  • Spreadsheet formulas. Paste a list of values into a function that expects them inline.

If a tool rejects your list, check three things: stray spaces, a trailing comma, and quotes of the wrong kind. Trim spaces and Remove blank lines are on by default, which fixes the first two. The Quotes menu fixes the third.

Large lists and privacy

The tool works on lists of 100,000 rows in well under a second. Everything runs in your browser, and your text is never uploaded.

Frequently asked questions

How do I convert a column to a comma separated list?

Copy the column from Excel, Google Sheets or your database tool. Paste it into the left box on this page. The comma separated list appears on the right. Press Copy to put it on your clipboard.

How do I make a list for a SQL IN clause?

Paste your column and click SQL IN list. The tool puts single quotes around text, leaves numbers bare, and wraps the list in parentheses. Tick Remove duplicates if the column repeats values. Oracle allows at most 1,000 items in one IN list.

Can I turn a comma separated list back into rows?

Yes. Choose List to column at the top of the tool. Paste the list and you get one value per line. Quotes and brackets are removed, and a quoted value that holds a comma stays whole.

How does it handle apostrophes such as O'Brien?

With single quotes on, the tool doubles the apostrophe, so O'Brien becomes 'O''Brien'. That is the standard way to escape a quote in SQL. The same rule applies to double quotes. The JSON array setting escapes a quote with a backslash instead, as JSON requires.

How do I keep leading zeros like 007?

Tick Do not quote numbers. Values such as 42 and 3.5 stay bare. A value with a leading zero is not treated as a number, so it keeps its quotes and its zeros.

Is there a limit on how many rows I can paste?

There is no set limit. A list of 100,000 rows converts in well under a second on a normal laptop. Very large pastes depend on your device and browser memory.

Is my data uploaded or saved?

No. The conversion runs in your browser. Your text is never sent to a server. Only your option choices, such as the separator, are saved on your own device.

Can I use a separator other than a comma?

Yes. Pick semicolon, pipe, new line, tab or space, or choose Custom and type your own, such as " - ". Use \t for a tab and \n for a new line.

Can I upload a file or download the result?

Yes. Press Upload file to load a .txt or .csv file, and Download .txt to save the result. The file is read in your browser and is not sent anywhere.

Can I paste several columns from Excel?

Yes. Tick Use only the first column in Options. The tool then keeps the text before the first tab on each row and ignores the rest.

Popular conversions

More free tools from Bingemind