EthicalFusion

List to Comma Separated

Turn a line-by-line list into a single comma-separated line (safely quoted).

Was this tool helpful?

Thanks for the feedback!

Paste a list with one item per line and this tool joins it into a single comma-separated line, quoting any item that itself contains a comma. It saves time when a form, query or setting wants values on one line but your data is in a column, for example a list copied from Excel, a text file or an email.

What the conversion does

  • Removes spaces at the start and end of each line.
  • Skips blank lines completely.
  • Joins items with a comma followed by a space.
  • Wraps an item in double quotes if it contains a comma or a double quote, and doubles any quote marks inside it, following CSV rules.
  • Keeps duplicates and the original order.

An Items counter under the result tells you how many values were joined, which is a quick check that nothing went missing.

Example

Input (with a blank line and stray spaces):

apple

  banana
red, ripe cherry
apple
say "hi"

Output:

apple, banana, "red, ripe cherry", apple, "say ""hi"""

"red, ripe cherry" was quoted so it stays one item when the line is read as CSV, and the quotes around "hi" were doubled for the same reason. The second "apple" is kept.

Common uses

SQL IN clauses with numeric IDs

A column of IDs such as 101, 102 and 103 becomes 101, 102, 103, ready for WHERE id IN (101, 102, 103). For text values, SQL needs single quotes around each item, such as 'Mumbai', 'Pune', which this tool does not add. Add them with find-and-replace, or put them on each line before converting.

Tags, keywords and recipients

Blog tags, product keywords and video tag fields usually take comma-separated values. Gmail's To field also accepts comma-separated addresses, so a column of emails copied from a sheet can be pasted in one go.

Config values and spreadsheet cells

Environment variables, allow-lists and single spreadsheet cells often expect a comma-separated string. Note the space after each comma: if a program splits on a bare comma, it may keep a leading space on every item except the first, so remove the spaces with find-and-replace when a strict format is required.

Cleaning the list first

Because duplicates are kept, run a long list through the Duplicate Line Remover first if every value should appear once. To sort items alphabetically before joining, use the A to Z text sorter. The joining is done by JavaScript in your browser, so the list stays on your device.

Limits

The separator is always a comma plus a space; there is no option for semicolons, tabs or pipes. Each line is treated as one item, so a line that already contains several comma-separated values is quoted as a single item rather than split.

Frequently asked questions

Does it remove blank lines and extra spaces?
Yes. Blank lines are skipped and spaces at the start and end of each line are trimmed.
Why is one of my items wrapped in quotes?
It contains a comma or a double quote, so it is quoted to show it is a single value when the line is read as CSV.
Does it remove duplicates?
No. Every line is kept in its original order. Remove duplicate lines first if you need unique values.
Can I use the output in a SQL IN clause?
Yes for numbers. Text values need single quotes around each item, which you have to add yourself.
Can I use a separator without the space?
The output always uses a comma followed by a space. Replace ", " with "," using find and replace if you need a compact list.

Related tools

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.