About the Text Separator
The Text Separator takes text that holds several items, splits it into those items and puts them back together in the format you need. Turn a comma-separated list into one item per line, a column into a comma list, or a row copied from a spreadsheet into a JSON array.
You can split at commas, semicolons, line breaks, spaces, tabs, pipes, any text you type, or a regular expression. The output can be one item per line, separated by commas, semicolons, pipes, tabs or spaces, wrapped in quotes, written as a JSON array, or formatted as a numbered or bulleted list.
Along the way, the tool can trim stray spaces, drop empty items, remove duplicates and sort the list. It all happens in your browser, so your text never leaves your device.
How to use it
- Paste your textPaste into the left box or drop a text file onto it. Sample loads a short list with an extra space, an empty item and a duplicate.
- Choose where to splitPick the separator your text uses now under Split at. For anything unusual, choose Custom text or Regular expression and type it in.
- Choose the output formatPick how the items should be joined under Output as, from one per line to a JSON array.
- Clean up the listTrim spaces, remove empty items and remove duplicates with the checkboxes, and pick an order: original, A to Z, Z to A or reversed.
- Copy or downloadThe status line shows how many items you have. Copy the result or download it as a .txt file.
Key features
Eight ways to split
Commas, semicolons, line breaks, spaces, tabs, pipes, your own text or a regular expression.
Twelve output formats
Lines, commas with or without a space, semicolons, pipes, tabs, spaces, quoted values, a JSON array, a numbered list, a bulleted list or your own separator.
Line breaks handled too
"Also split at line breaks" is on by default, so a list that uses both commas and new lines is split correctly.
Clean-up built in
Trim spaces around items, drop empty items and remove exact duplicates in the same step.
Natural sorting
A to Z puts file2 before file10 and ignores the difference between capital and small letters.
Private by design
There is no upload and no account. The text is split on your own device.
Examples
From a messy comma list to clean lines
The Sample button loads this text, which has an extra space, a double comma and a repeated item:
apples, pears , plums,, cherries
lemons, apples, limes
With the default settings (split at commas, one per line), you get 7 items: apples, pears, plums, cherries, lemons, apples and limes. The spaces are trimmed and the empty item between the two commas is gone.
| Change | Result |
|---|---|
| Remove duplicates, A to Z, Comma and space | apples, cherries, lemons, limes, pears, plums |
| Remove empty items off | 8 items, with an empty line where the double comma was |
| Also split at line breaks off | 6 items, because "cherries" and "lemons" stay together in one item |
Output formats
Here is the list milk, eggs, bread in some of the output formats:
| Output as | Result |
|---|---|
| Numbered list | 1. milk 2. eggs 3. bread |
| Bulleted list | • milk • eggs • bread |
| Quoted, comma separated | "milk", "eggs", "bread" |
| JSON array | ["milk", "eggs", "bread"], one item per line with two-space indents |
| Pipe separated | milk|eggs|bread |
Splitting at several separators at once
Some lists mix separators. Choose Regular expression and enter the pattern [;,|] to split at semicolons, commas and pipes together:
red; green,blue | yellow
The result is four items: red, green, blue and yellow.
Other common jobs
| Input | Settings | Result |
|---|---|---|
| A spreadsheet row: Name, Email and City in three cells | Split at tabs | One heading per line |
Paris - London - Rome | Custom text " - ", custom separator " / " | Paris / London / Rome |
first, second, third | Reversed | third, second, first |
Tips
- Copying cells from Excel or Google Sheets gives tabs between cells in a row and line breaks between rows. Split at tabs with "Also split at line breaks" on, and every cell becomes its own item.
- For an SQL IN list of text values, use Custom separator with ', ' (quote, comma, space, quote). You get 101', '102', '103, and only need to add a quote at the very start and end.
- Choose JSON array when you need a list in code or a config file. Quotes, backslashes and other special characters inside items are escaped correctly.
- Turn on Remove duplicates and sort A to Z to build a clean tag or keyword list from several sources in one step.
- If you only need to join lines or remove line breaks inside sentences, Remove Line Breaks has options made for prose, such as keeping paragraphs.
Common mistakes and limits
- Splitting text that contains the separatorA value like "Smith, John" is split into two items at its comma. If your items contain commas, split at line breaks, tabs or another character instead.
- Using capturing groups in a patternParentheses in a regular expression make the separators show up as items of their own: ([;,]) turns "red; green" into red, ; and green. Use [;,] or a non-capturing group (?:;|,) instead.
- Expecting Remove duplicates to ignore caseIt removes only exact copies after trimming. "Apple", "apple" and "APPLE" stay three items. Remove Duplicate Lines has a Match case switch for that.
- Using quoted output for CSV or SQLQuotes inside an item are escaped with a backslash (\"), the way JavaScript and JSON do it. CSV files and SQL expect quotes to be doubled instead, so check items that contain quotes.
- Splitting at Spaces with tabs in the textThe Spaces option splits at one or more spaces, not at tabs. Choose Tabs or a regular expression such as \s+ for text with mixed whitespace.