How to use the list to comma separated
- Paste your list with one item per line, for example from Excel or a database.
- Pick quotes and a separator if you need them.
- Copy the single-line result.
About this tool
Copy a column from Excel, Google Sheets or a database, paste it here, and get a single comma separated line. Blank lines are dropped and each item is trimmed. Choose no quotes, single quotes or double quotes, and pick a comma, comma with space, semicolon or pipe as the separator.
Turn a column into a comma separated list in three steps
Select the cells in Excel or Google Sheets and copy them. Paste into the box on the left, where each cell becomes one line. The single-line result appears on the right, ready to copy. Blank lines are skipped and spaces around each item are trimmed.
Example
Three lines of input, and the output for each quote setting:
| Setting | Output |
|---|---|
| Input | red / green / blue (one per line) |
| No quotes | red,green,blue |
| Single quotes | 'red','green','blue' |
| Double quotes | "red","green","blue" |
Using the result in a SQL query
The most common use is an IN clause. Choose single quotes, copy the result and wrap it in brackets: WHERE city IN ('Pune','Delhi','Chennai'). Numeric IDs need no quotes, so use the plain setting for them.
Two cautions. If a value itself contains a single quote, double it (O''Brien) or the query will break. And Oracle allows at most 1,000 items inside one IN list, so for longer lists load the values into a temporary table and join to it instead.
Using it in code
Pick double quotes and add square brackets to get a JavaScript, JSON or Python list, for example ["red","green","blue"]. You can paste it into the JSON formatter to confirm it is valid. For a CSV row, use the plain setting and a comma.
Excel alternative
If you want to stay inside Excel 2019 or Microsoft 365, the formula =TEXTJOIN(",",TRUE,A1:A10) joins a range with commas and skips blanks. This page is quicker when you need quotes around every item or you are not working in a spreadsheet.
Choosing a separator
Comma is standard for SQL, CSV and most programming languages. Use comma with space for readable text, semicolon for CSV files in regions where the comma is the decimal mark, and the pipe character when your values may contain commas.
Frequently asked questions
Does it remove blank lines?
Yes. Empty lines are skipped and each item is trimmed.
Can I use it for SQL IN clauses?
Yes. Choose single quotes and a comma, then wrap the result in parentheses.
Is there a size limit?
There is no fixed limit. Very large lists depend on your device memory.
How do I convert a comma separated string back to a list?
Paste it into a text editor and replace each comma with a new line. A find-and-replace using \n works in most editors, or use the Sort Lines tool afterwards to tidy it.
Does it remove duplicates?
No. Run the list through the Remove Duplicate Lines tool first if you need unique values.