Skip to content
cliplimeClipLime

Add commas to a list

Turn lines or words into a comma separated list, in the layout you need.

Your list

0 characters, 0 lines

Convert to

How the commas are placed.

Clean up

Ready made styles

More options

Use \n for a new line and \t for a tab in any of these boxes.

Result

Your list is converted in this tab. Nothing is uploaded.

At a glance

What it does
Adds commas to a list: items on separate lines, or words separated by spaces, become a comma separated list.
Three layouts
One line with commas and spaces (a, b, c), a comma at the end of every line, or commas with no spaces (a,b,c).
Input
Detects lines, words separated by spaces, tabs or semicolons for you, or you can choose the separator yourself.
Trailing comma
Choose whether the last item also gets a comma. Many programming languages allow one, and JSON does not.
Quotes
Add single or double quotes around each item, ready to paste into code, a query or a spreadsheet formula.
Clean up
Remove duplicates and empty lines, trim spaces and sort at the same time.
Privacy
Your list stays in your browser.

How to do it

  1. 1

    Paste your list

    Paste items on separate lines, or words separated by spaces. A column copied from a spreadsheet works as it is.

  2. 2

    Choose a layout

    Pick One line, Comma at the end of each line, or No spaces. The commas are added right away.

  3. 3

    Add quotes if you need them

    Wrap each item in single or double quotes if the list is going into code or a query.

  4. 4

    Copy the list

    Copy the result. Use Separator after the last item under More options if you want a comma after the final item too.

Three ways to write a list with commas

The same items can be written with commas in three common ways, and the layout buttons switch between them:

  • One line: red, green, blue. The usual way to write a list in a sentence, a form field or a search box. Each comma is followed by a space.
  • Comma at the end of each line: red, then green, then blue on the next lines. This keeps one item per line, which is how items are listed in code arrays, config files and long lists you want to read and edit.
  • No spaces: red,green,blue. Used for URLs, command line options and some import fields that do not allow spaces.

The comma after the last item

In the line by line layout, the last item has no comma by default, because that is what most lists want. Some languages, including JavaScript, Python and Rust, allow a comma after the final item in a list, which makes lines easier to add and move around. JSON does not allow it, and neither do most import forms, so leave it off unless you know the place you are pasting into accepts it.

Under More options, the Separator after the last item switch adds it back.

Numbers, words and quotes

For a list of numbers, such as 3 and 14 and 159, leave quotes off: 3, 14, 159. For a list of words or names that is going into code, a database query or a spreadsheet formula, add quotes: 'red', 'green', 'blue' for SQL, or "red", "green", "blue" for most programming languages. The SQL IN list style does this and adds the brackets as well.

If an item contains the quote character itself, such as O'Brien inside single quotes, it is escaped when you add quotes. By default a backslash is put in front of it. You can choose to double it instead, which is what SQL and CSV use.

Questions people ask

How do I add a comma to the end of each line?

Paste the lines and press Comma at the end of each line. Every line except the last gets a comma. Use Separator after the last item under More options if the last line needs one too.

How do I add commas between words separated by spaces?

Paste the words on one line. The tool sees a line with spaces and no other separators, splits on the spaces, and joins the words with commas. Choose Space or any whitespace under Items are separated by if it is not detected.

Should there be a space after each comma?

In text meant for people, yes: red, green, blue. In data that a program reads, such as a URL parameter, no space is safer: red,green,blue. The layouts One line and No spaces give you both.

Can I add a comma to a list that already has commas?

A single line of comma separated items is split on its commas and joined again, so you can change the spacing or the layout. If every line already ends in a comma, those commas are taken off first, so you do not get double ones. If only some lines have commas, remove them first, because the tool cannot tell which ones you meant.

How do I remove the comma at the end of the list?

Leave Separator after the last item off, which is the default. If your list already has a comma at the end of every line, Remove commas at line ends takes them off before the commas are added again.

Is my list uploaded?

No. Everything runs in your browser and nothing is sent anywhere.

Guides that help

All Text guides →