LTLine Toolkit

Tools / Convert a comma-separated list to lines

Convert a Comma-Separated List to Lines

Split a comma-separated list into one item per line. Quoted values containing commas stay whole instead of splitting.

Everything runs in your browser. Your text is never uploaded or stored.

How it works

Splitting on a comma with a naive find-and-replace breaks the moment a value contains a comma of its own. Smith, John becomes two lines, and the list silently gains an item. That is the single most common cause of broken CSV imports, because CSV wraps a field containing a comma in double quotes precisely to prevent this.

This splitter is quote-aware. It tracks whether it is inside a quoted field, so a comma between quotes is treated as part of the value and not as a separator. A doubled quote inside a quoted field, "", is read as one literal quote character, which is the CSV convention. That covers the vast majority of real exports without needing a full CSV parser.

Edge cases

Do it in code instead

The same result with a shell one-liner or a few lines of Python, if you would rather automate it:

Bash (tr, no quote support)

tr ',' '\n' < list.txt

Python (csv module)

import csv
print('\n'.join(next(csv.reader([open('list.txt').read()]))))

JavaScript

text.match(/"([^"]|"")*"|[^,]+/g).map(s => s.trim())

Excel

Data > Text to Columns > Delimited > Comma

Questions

Does it handle quoted values with commas?
Yes. Double-quoted fields are respected, so a value like "Kathmandu, Nepal" is kept as one item. That is the behaviour CSV expects and the reason the quotes exist.
Why did my whole line become one item?
An unbalanced quote leaves the parser inside a quoted field, so it never sees a separator again. Check for an odd number of double quotes and fix it before splitting.
Can I split on a semicolon instead?
Yes. Semicolon is offered because many European CSV exports use it as the field separator to avoid conflict with the decimal comma.

Last verified: 2026-12-04