Comma to Lines Converter
Split a comma-separated list into one item per line, trimming spaces and dropping empty items, ready to paste into a spreadsheet column.
The interactive tool loads here when JavaScript runs.
About this toolWhat is Comma to Lines?
Comma to Lines splits a comma-separated list into one item per line. Spaces around each item are trimmed and empty items, such as those created by a doubled comma or a trailing comma, are dropped.
It is the reverse of Lines to Comma. Paste a tag list, a set of IDs from a log message, a list of recipients or an exported array and get a column you can paste straight into a spreadsheet, sort or deduplicate.
The split happens at every comma. Commas inside quotes are not treated specially, so "Smith, John" becomes two lines. For real CSV files with quoted fields, use the CSV to JSON converter. Conversion runs in your browser.
- Splits on every comma
- Trims spaces around each item
- Drops empty items from doubled or trailing commas
- One-click copy
- Runs in your browser; nothing is uploaded
Updated
How to use Comma to Lines
- Paste the comma-separated text into Input Text.
- Click Convert to Lines.
- Check Output Text, which has one trimmed item per line.
- Click Copy Result and paste the column wherever you need it.
Worked examples
A messy tag list
Input
red, green,,blue , yellow,
Output
red green blue yellow
The doubled comma and the trailing comma would produce empty items; they are dropped. Spaces before and after each tag are trimmed.
Where a plain split goes wrong
Input
"Smith, John", Jane
Output
"Smith John" Jane
The comma inside the quoted name is also a split point. Parse quoted CSV with a CSV-aware tool instead.
Background and insight
Splitting on a comma is the simplest form of tokenising, and it is the same thing as String.split(',') in JavaScript or str.split(',') in Python, plus a trim. Those two languages differ on edge cases (Python's split with no argument collapses whitespace, with an argument it keeps empty strings), which is why this tool explicitly removes empty items rather than leaving blank lines.
The usual trap is quoted values. RFC 4180 CSV allows a comma inside a field if the field is wrapped in double quotes, and JSON arrays contain quoted strings that may themselves contain commas. A naive split cannot know about either. When the list came from a CSV file or a JSON array, parse it as that format instead.
Lists from other systems sometimes use semicolons (Excel in many European locales writes CSV with semicolons, because the comma is the decimal separator there), pipes or tabs. Replace the separator with a comma first, using Find & Replace in the Online Text Processor.
Common use cases
Spreadsheet columns
Turn a comma list from an email or a ticket into a column to paste into Excel or Google Sheets.
Reviewing tags
Split a CMS tag field into lines so you can sort it, spot duplicates and fix typos.
Reading log values
Break a comma-joined list of IDs from a log message into lines for searching.
Preparing for comparison
Split two comma lists into lines and compare them with the List Comparison tool.
Tips and limitations
- Commas inside quoted values are split too. Use the CSV to JSON converter for real CSV.
- For semicolon or pipe separated lists, replace the separator with a comma first in the Online Text Processor.
- Empty items are always removed, so "a,,b" gives two lines, not three. If empty positions matter, this is the wrong tool.
- Chain it with Remove Duplicate Lines or the Sort Lines button in the Online Text Processor to tidy the result.
Sources and further reading
- RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files, IETF. Quoted fields may contain commas
- String.prototype.split(), MDN Web Docs
- Built-in Types: str.split, Python Software Foundation. How split behaves with and without a separator
Frequently asked questions
How do I split a comma-separated list into rows in Excel?
Paste the list here, click Convert to Lines, copy the result and paste it into a single cell in Excel; each item lands in its own row. Inside Excel, Data > Text to Columns splits into columns rather than rows, so you would need Paste Special > Transpose as a second step.
Why are some of my items split in the middle?
They contain a comma. The tool splits at every comma, including ones inside quotes, so "Smith, John" becomes "Smith and John" on two lines. For properly quoted CSV data, use the CSV to JSON converter, which follows the CSV quoting rules.
What happens to empty items like a,,b?
Empty items are dropped, so a,,b becomes two lines, a and b. Trailing commas are handled the same way. This keeps the output clean for lists of tags or IDs, but it means you cannot use this tool when empty positions are meaningful, such as in fixed-column data.
Can I split on semicolons or pipes instead of commas?
Not directly, the separator is always a comma. Open the Online Text Processor, use Find & Replace to change ; or | to a comma, then run Comma to Newline there or paste the result here. Excel exports in some European locales use semicolons for this reason.
Does Comma to Lines remove duplicate items?
No, every item is kept in its original order. Paste the result into Remove Duplicate Lines to drop repeats, or into Find Duplicate Entries to see which ones repeat and how often.
Is there an in-depth guide to Comma to Lines?
Yes. “Cleaning Up Text Lists: Spaces, Blank Lines, Duplicates and Commas” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.