Practical guidesLists & tables

Add a comma to the end of each line.

Add a comma, quotes or other text to the start or end of every line in a list, or join the list into one comma-separated line. Worked examples included.

Open the text cleanup

Two different results

Adding commas to a list can mean two things. You may want to keep one item per line and put a comma at the end of each, which is common in code and config files. Or you may want all the items on one line, separated by commas, for pasting into a form, an email or a query. Toolpane has a tool for each, and this guide covers both.

Keep one item per line with Suffix

Open Text cleanup and paste your list into Your text. Type a comma in Suffix. Every line in the result ends with a comma.

Check the other options before you copy. Remove duplicates, Remove blank lines and Trim whitespace are all on by default; untick Remove duplicates if repeated lines must stay. Sort lines is set to Keep original order, so the order does not change unless you choose a sort.

Example input

apple
banana
cherry

Example result

apple,
banana,
cherry,

Deal with the last comma

The suffix is added to every line, including the last. Many formats, such as JSON and older SQL dialects, do not allow a comma after the last item, so delete it by hand after pasting. If you need the result ready to use as code, the JSON array or SQL IN output of the comma separator handles the commas and quoting for you.

Add quotes as well

Use Prefix and Suffix together to wrap each line. A prefix of a single quote and a suffix of a single quote and a comma gives quoted lines. This adds characters literally: an apostrophe inside a value, as in O'Brien, is not escaped. Use the SQL IN strings or Double-quoted strings formats in the comma separator when values may contain quotes.

Example input

Prefix: '
Suffix: ',

apple
banana
cherry

Example result

'apple',
'banana',
'cherry',

Put everything on one line

To join the list into a single line, open the comma separator, paste the list and leave Output format on Comma-separated. The separator is a comma and a space by default; change it to a plain comma or a semicolon if needed. There is no trailing comma. The Excel column guide has more detail, including quoting options.

Example input

apple
banana
cherry

Example result

apple, banana, cherry

Common questions

Can I add text to the start of each line? Yes, use Prefix, for example a hyphen and a space to make a bullet list.

Can I keep editing the result? Apply to input moves the result into Your text so you can run another step, and Undo reverses it.

Does it work with spreadsheet columns? Yes. A copied column pastes as one value per line.

Open the text cleanup