Skip to contentSkip to the inputSkip to the result

List ↔ comma separated

Turn lines into a comma list and back

Loading tool

Instructions

List ↔ comma separated

How to use

  1. Enter the list and choose the direction, separator, quotes and clean-up.

Supported input

  • Up to 200,000 characters.
  • Empty items are dropped and items are trimmed.
  • Duplicates can be removed and items sorted (numbers by size), and SQL quotes double any single quote inside an item.

Input example

apple
pear
plum

Result example

apple, pear, plum

Troubleshooting

  • Nothing is produced for empty input.
  • Split very long text into parts.

Limitations

  • CSV quoting rules, such as commas inside quotes, are not applied.

How it works

  • Joins a one-per-line list with commas or tabs, or splits comma-separated text into lines.

Lines to commas and back: choosing separators and quotes

Where the list is going

  • A numeric SQL column: 1001, 1002, 1003 with no quotes drops straight into WHERE id IN (…).
  • One spreadsheet row: joined with tabs, a vertical list pastes across the columns of a single row.
  • An email To field: Outlook and some other clients separate addresses with semicolons, so choose “; ”.
  • Hashtags: #travel, #autumn and #seoul joined with spaces give “#travel #autumn #seoul”.
  • A code array: wrap items in double quotes, join with commas and add [ ] around the result for JavaScript or JSON.

Worked example: what the clean-up options change

Input, eight lines: apple, pear, a blank line, “ plum ” with spaces around it, apple, it’s written with a straight apostrophe, 10 and 2.

  1. 1As is, no quotes: apple, pear, plum, apple, it's, 10, 2. The blank line is dropped and plum is trimmed, leaving 7 items.
  2. 2SQL quotes, remove duplicates: 'apple', 'pear', 'plum', 'it''s', '10', '2'. Six items, with one duplicate removed reported alongside.
  3. 3Double quotes, remove duplicates and sort: "2", "10", "apple", "it's", "pear", "plum". Numbers come first in order of size, then words alphabetically.

Backslashes and JSON

Double-quote mode puts a backslash before any double quote inside an item but leaves existing backslashes alone. say "hi" correctly becomes "say \"hi\"", but the Windows path C:\temp comes out as "C:\temp".

In JSON (RFC 8259) \t inside a string means a tab, so a JSON parser reads that value as C:, a tab, then emp. For items containing backslashes, first double every backslash with find and replace, or build the JSON another way.

Splitting does not follow CSV quoting

Under the CSV standard, RFC 4180, a comma inside a double-quoted field is part of the value. This tool splits at every comma, tab, semicolon and line break first, then removes one pair of quotes around each item.

So "a","b, c","d" gives four items, a, "b, c" broken into two pieces, and d, instead of three. Empty items are dropped too, so “Leeds,, York” gives two. For real CSV with quoted commas, use the CSV to JSON tool, which reads the quotes properly.

Common mistakes

  • Quoting numbers for SQL: '10' is a string, which depending on the database forces a type conversion or stops an index from being used. Leave numeric IDs unquoted.
  • Joining with spaces and expecting to split back: One line → lines does not split on spaces, so “#travel #autumn #seoul” comes back as a single item. Join with commas or semicolons if the list must round-trip.
  • Sorting when order matters: Remove duplicates and sort reorders everything. Choose Remove duplicates alone to keep the original order.

Checked

Frequently asked questions

How do I turn a spreadsheet column into a list for an SQL IN clause?

Paste the column, then choose Lines → one line, Comma and single quotes to get 'a', 'b', 'c'. Add the surrounding brackets yourself.

What happens to an apostrophe inside an item?

With single or double quotes, a matching quote inside an item gets a backslash, so it's becomes 'it\'s'. For SQL, choose the SQL quotes, which double the quote: 'it''s'.

Can I remove duplicates or sort the list?

Under Clean-up, Remove duplicates keeps the first of each item in the original order, and Remove duplicates and sort also sorts them, numbers by size so 2 comes before 10. The number of duplicates removed is shown with the result.

What does One line → lines split on?

Commas, tabs, semicolons and line breaks; spaces are not separators. 'New York, Paris' gives two items, and a comma inside quotes still splits.