OnlineTextLab
Esc

Text Joiner

Turns a column of values into one line: a comma-separated list, a quoted SQL list, or text with its broken lines repaired.

Write \n for a new line and \t for a tab.

Ctrl or Cmd + Enter copies the result.

Runs on your device. Your files and text are not uploaded.

About Text Joiner

Spreadsheets and exports give you data in columns, while the place it needs to go often wants one line: an SQL IN (...) clause, a search filter, the recipients field of an email. Paste the column and it is joined as you type, with , as the separator to begin with. Change that to a pipe, a tab, or anything else, and the result follows.

Add text before and after each item to wrap it. A single quote on both sides is all it takes to produce '1042', '1043', '1044', ready for a query. Stray spaces from copying are trimmed, and blank lines are skipped, so an empty row cannot turn into '' in your SQL.

The same tool repairs text with hard line breaks, the kind you get from PDFs and old emails. Join with a space and each sentence flows normally again.

How it works

The text is split at line breaks, and a final line break is ignored so it does not add an empty item at the end. Trim spaces removes whitespace from both ends of each line, and Skip blank lines drops any line left empty, in that order. Each remaining line then gets your Before each item and After each item text, and the items are joined using the separator.

Separators are taken literally, with three escapes for characters that are hard to type: \n for a new line, \t for a tab and \s for a space. Using \n\n turns a list into paragraphs with a blank line between them.

Nothing inside an item is escaped. If a value contains a quote or your separator, it stays as written, so check values such as O'Brien before pasting them into SQL.

How to use Text Joiner

  1. Paste your lines into the Lines to join box, or press Upload. Try an example shows a list with stray spaces and a gap.
  2. Set the Separator, or press Comma, Space, Pipe or Tab.
  3. Fill in Before each item and After each item if you want each value wrapped.
  4. Leave Trim spaces and Skip blank lines on, unless your data needs them.
  5. Take the single line with Copy, or Ctrl or Cmd + Enter. Download saves it as joined-lines.txt.

A column of order IDs, ready for an SQL query

Input
1042
1043

1044
Output
'1042', '1043', '1044'

Separator is , , and a single quote goes in both Before each item and After each item. The blank row disappears because Skip blank lines is on, and the count reads 3 items joined.

When it helps

  • Building an SQL IN list from a spreadsheet column.
  • Turning a column of email addresses into one line for the To field.
  • Repairing text from a PDF, where every line ends with a hard break, by joining with a space.
  • Writing a regex alternation by joining words with |.
  • Making a JSON array by wrapping each item in double quotes and adding square brackets by hand.

Tips for a better result

  • When rejoining text from a PDF, keep paragraphs apart by joining each paragraph separately, because every line break gets replaced, including those between paragraphs.
  • Paste a column straight from Excel or Google Sheets. Each cell arrives on its own line, which is what the tool expects.
  • To go the other way, from one line to a column, use the Text Splitter with a separator, or replace , with \n in Find and Replace.
  • Sort or deduplicate first if the list has repeats. An IN list does not need the same value twice.

Good to know

  • It joins lines only. To merge columns side by side, use a spreadsheet, where a formula can combine them row by row.
  • It does not escape anything, so it is not a safe way to build SQL from data you do not trust. Use your database's parameterized queries for anything that takes user input.
  • To put a literal \n in the output, write \\n, since a plain \n becomes a line break.
  • Hyphenated words broken across lines stay broken, as in exam- ple. Fix those afterwards with Find and Replace.

Questions people ask

How do I turn a column into a comma-separated list?

Paste the column into the box. The default separator is a comma and a space, so the list appears right away. Press Comma, or edit the Separator box and remove the space if you need a,b,c.

How do I add quotes around each item?

Type the quote mark in both Before each item and After each item. Use a single quote for SQL strings, and a double quote for JSON or CSV.

How do I remove line breaks from a paragraph?

Press Space to make the separator a single space. All the lines flow into one. Do this for one paragraph at a time, since all line breaks in the box get replaced, including those between paragraphs.

What to use next

Last reviewed . Read our editorial policy.