Text Separator

Split text by any delimiter and join it back with the separator you need.

  • Runs in your browser
  • Free, no sign-up
Paste text to start

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

  1. 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.
  2. 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.
  3. Choose the output formatPick how the items should be joined under Output as, from one per line to a JSON array.
  4. 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.
  5. 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.

ChangeResult
Remove duplicates, A to Z, Comma and spaceapples, cherries, lemons, limes, pears, plums
Remove empty items off8 items, with an empty line where the double comma was
Also split at line breaks off6 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 asResult
Numbered list1. 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 separatedmilk|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

InputSettingsResult
A spreadsheet row: Name, Email and City in three cellsSplit at tabsOne heading per line
Paris - London - RomeCustom text " - ", custom separator " / "Paris / London / Rome
first, second, thirdReversedthird, 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.

Frequently asked questions

How do I turn a comma-separated list into one item per line?
Paste the list, choose Split at Commas and Output as One per line. These are the default settings, so most lists are converted the moment you paste them.
How do I make a comma-separated list from a column?
Choose Split at Line breaks and Output as Comma separated, or Comma and space if you want a space after each comma.
What does "Also split at line breaks" do?
It splits at line breaks in addition to the separator you picked. That way a list that continues over several lines does not end up with two items stuck together. It has no effect when you already split at line breaks.
Can I split at more than one character?
Yes. Choose Custom text and type any sequence, such as " - " or " and ". For several different separators at once, choose Regular expression and use a pattern like [;,|].
What does the JSON array output look like?
A standard JSON array with each item as a string on its own line, indented by two spaces. You can paste it straight into JavaScript, Python or a JSON file.
How does sorting work?
A to Z and Z to A compare numbers by value and ignore case, so File1, file2 and file10 come out in that order. Reversed simply flips the original order.
Why do I get an error when I use a regular expression?
The pattern has a syntax error, such as an unclosed bracket. The status line shows what is wrong. If you meant to split at a symbol like [ or (, use Custom text instead.
Is my text saved or sent anywhere?
No. Splitting happens on your device and nothing is uploaded. Reload the page and the text is cleared.