Comma Separator

Convert a list of lines into a comma-separated list, and back again.

Everything runs in your browser. Nothing you type is uploaded or stored.

In-depth guide

Comma separator: lists to CSV-style text and back

Exactly how lines become a comma-separated list (and back), how quoting and escaping work (quotes are doubled, as CSV and SQL expect), and where it still falls short of a real CSV parser.

Last verified: Plain-text version of this guide

Key figures at a glance

Directions
Lines to commas, and commas to lines
Chosen with the Direction menu.
Joiner
Comma plus one space
Items are joined with , ; an optional trailing comma can be added.
Quote escaping
The quote character is doubled
it's becomes 'it''s' in single quotes and say "hi" becomes "say ""hi""" in double quotes, as SQL and CSV expect.
Comma to lines
Quote-aware splitting
A quoted field may contain commas and doubled quotes; 1,200 still becomes two items.

Lines to comma-separated

In the default direction the tool does this to the text, in your browser:

  1. Split into lines (\r\n, \r and \n).
  2. Trim each line's surrounding whitespace and discard empty lines.
  3. Optionally wrap each item in single or double quotes.
  4. Join with a comma and one space (, ). Tick Trailing separator to add a final comma.

Spaces inside an item are kept: a b c stays one item. An empty input gives an empty result.

Example input, with an indented line, an empty line and a Windows line ending:

apple
  banana 
(empty line)
cherry
it's
Quote option Output
No quotes apple, banana, cherry, it's
Single quotes 'apple', 'banana', 'cherry', 'it''s'
Double quotes, trailing comma "apple", "banana", "cherry", "it's",

How quotes are escaped

When quoting is on, the tool doubles any occurrence of the same quote character inside an item: it's in single quotes becomes 'it''s'; say "hi" in double quotes becomes "say ""hi""". The other kind of quote is left alone (it's in double quotes stays "it's") and backslashes are not touched (back\slash stays back\slash).

This is what both common destinations expect:

  • CSV. RFC 4180 escapes a double quote inside a quoted field by doubling it: "b""bb". A backslash is just an ordinary character in CSV. Use double quotes for CSV.
  • Standard SQL / PostgreSQL. A single quote in a string constant is written as two single quotes ('it''s'). With standard_conforming_strings on (the default since PostgreSQL 9.1) a backslash in an ordinary constant is literal, so a backslash escape such as 'it\'s' would be broken. Use single quotes for SQL.

Tip: Use this tool for lists of simple values such as IDs, tags or e-mail addresses. For values that come from users, do not paste the result straight into SQL or CSV. Use your database's parameterised queries or a CSV library, which also protects against injection.

Comma-separated to lines

Choosing the other direction does the reverse:

  1. Walk through the text and split at every comma, except inside quotes: a piece that starts with a single or double quote (after optional spaces) runs to the matching closing quote, so commas inside it do not split it.
  2. Inside a quoted piece, two quote characters in a row become one literal quote, so "say ""hi""" gives say "hi".
  3. Trim unquoted pieces, drop empty pieces and join with new lines.
  4. If a quote is opened and never closed, the whole text is split on plain commas instead and the quote characters at the ends of each piece are stripped, so one stray apostrophe such as 'tis cannot swallow the rest of the list.

Examples:

Input Output
a, b,,'c', "d" ,e a, b, c, d, e on separate lines
'it''s', "x, y", z it's, x, y, z
"say ""hi""", "ok" say "hi", ok
1,200, 3,400 1, 200, 3, 400
a;b a;b (only commas split)
'tis, fine tis, fine (the unclosed quote is ignored)

The tool is still not a full CSV parser: it treats single quotes as quotes too, only the ASCII comma separates items, a quoted field that contains a line break comes out as two lines, and numbers with thousands separators are split. For real CSV files use a spreadsheet or a proper parser.

Common mistakes

  • Pasting the result into a SQL query built from untrusted values. The quotes are valid SQL, but parameterised queries are still the safe way.
  • Using double quotes for SQL: SQL string constants use single quotes, while double quotes suit CSV.
  • Expecting the separator to be only a comma. The joiner is a comma and a space, so remove the spaces afterwards if your format needs a,b,c.
  • Forgetting that blank lines are dropped, so a blank row will not become an empty list entry.

Text sorter sorts and de-duplicates the lines before you join them. Remove line breaks joins lines with spaces instead. Text repeater makes a repeated list quickly. Word counter counts the lines and words in your list.

Frequently asked questions

Is my text sent to a server?

No. Everything runs in your browser using JavaScript. Nothing you type or paste is uploaded, logged or stored anywhere.

Is there a length limit?

There is no fixed limit — the practical ceiling is your browser's memory. Documents of tens of thousands of words are handled comfortably.

Does it handle non-English text?

Yes, text in any language is kept as typed. The tool only splits on the plain comma (,), so a Chinese comma (,) or enumeration comma (、) is not treated as a separator.

Does it change my original text?

No. Your input stays exactly as you typed it; the result is produced separately so you can adjust the options and compare.

Sources

  1. RFC 4180 — Common Format and MIME Type for CSV Files — Quotes inside quoted fields are escaped by doubling.
  2. PostgreSQL — String constants — A single quote in a string constant is written as two single quotes; backslashes are literal by default.

This guide explains published rules in plain language. It is not financial, legal or official advice — rules change, so confirm with the agency linked above before you commit.

Related tools