↔

Join Lines

Combine multiple lines using spaces, commas, or a custom separator

Join Lines — what it does

Combine multiple lines of text into one, joined by a space, a comma or a separator you specify, with options to trim each line and drop empty ones. It is the reverse of splitting text into lines, and the fastest way to turn a copied column into a usable list.

Worked example

A column of addresses copied from a spreadsheet (with trailing spaces, a blank line and a final line break) joined with the Comma separator; Trim and Remove empty lines were left ticked.

Input text

ann.lee@example.com   
  mark.chen@example.com

sales@example.com
support@example.co.uk

Output — joined with comma

ann.lee@example.com, mark.chen@example.com, sales@example.com, support@example.co.uk

The Comma option inserts a comma followed by a space. With Trim and Remove empty lines unticked, the same input becomes one string with doubled separators and the stray spaces kept.

When this tool helps

  • Turning a column copied from a spreadsheet into a comma-separated list for a query or a form.
  • Rejoining hard-wrapped text into flowing paragraphs for reuse elsewhere.
  • Building an IN clause or an array literal from a list of identifiers.

How to use it

  1. Paste the multi-line text.
  2. Choose a separator: space, comma or custom.
  3. Enable trimming and removal of empty lines as needed.
  4. Process and copy the joined result.

Accuracy, limits, and good practice

  • Trim each line when the source came from a spreadsheet, or trailing spaces will end up embedded in the joined string.
  • A comma plus a space reads better in prose; a bare comma is what most code and query contexts expect.
  • Remove empty lines first, otherwise blank entries appear as doubled separators in the middle of the result.
  • Watch for a trailing separator on the last item; a stray comma at the end of a list breaks JSON and some query syntaxes outright.

Frequently asked questions

How do I quote each item?

Add quotes to every line first with the line prefix and suffix tool, then join with a comma.

Can I use a tab as the separator?

Use the custom separator field. Tabs are the right choice when the result is pasted back into a spreadsheet row.

How do I split text back into lines?

The list formatter converts joined text into bullets, numbered lines, CSV or a JSON array.

How do I join into fixed-size groups?

Not directly. Split the list into groups first, then join each group separately.

Is the custom separator trimmed?

No, it is used exactly as typed, spaces included, so " | " gives "a | b" and "; " gives "a; b". Leave it empty and the lines are concatenated with nothing between them.

What happens to a blank last line?

Text pasted from a spreadsheet often ends with a line break, which the tool sees as an empty final line. With Remove empty lines ticked (the default) it is dropped; unticked, it produces a trailing separator, such as a comma or a space at the very end of the result.

Related tools on this site

Everything above runs inside this page. Join Lines needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

合併文字行能做什麼

把多行文字合併成一行,以空格、逗號或你指定的分隔符連接,並可選擇修剪各行與移除空行。它是「把文字拆成多行」的反向操作,也是把複製下來的一欄資料變成可用清單最快的方式。

實際範例

從試算表複製的一欄地址(帶尾端空格、一個空行與結尾換行),以逗號分隔符合併;去頭尾空白與去空行維持勾選。

原文

ann.lee@example.com   
  mark.chen@example.com

sales@example.com
support@example.co.uk

合併後(逗號)

ann.lee@example.com, mark.chen@example.com, sales@example.com, support@example.co.uk

逗號選項會插進一個逗號加一個空格。若取消去頭尾空白與去空行,同一份原文會變成一條帶重複分隔符、保留多餘空格的字串。

什麼時候用得上

  • 把從試算表複製的一欄,轉成查詢或表單可用的逗號分隔清單。
  • 把硬換行的文字重新接回連續段落,方便在他處重用。
  • 從識別碼清單組出 SQL 的 IN 條件或陣列字面值。

使用步驟

  1. 貼上多行文字。
  2. 選擇分隔符:空格、逗號或自訂。
  3. 視需要開啟修剪與移除空行。
  4. 執行處理並複製合併結果。

精確度、限制與實務建議

  • 來源若來自試算表請開啟逐行修剪,否則尾端空白會被夾進合併後的字串裡。
  • 文章中用「逗號加空格」比較好讀;程式與查詢情境多半只要單純的逗號。
  • 請先移除空行,否則空白項目會在結果中間變成連續兩個分隔符。
  • 注意最後一項後面是否多了分隔符;清單結尾多一個逗號,會直接弄壞 JSON 與部分查詢語法。

常見問題

怎麼幫每個項目加引號?

先用每行前後綴工具為每行加上引號,再以逗號合併。

可以用 Tab 當分隔符嗎?

請用自訂分隔符欄位。結果要貼回試算表的同一列時,Tab 正是正確選擇。

怎麼把文字再拆回多行?

清單格式轉換工具可把合併後的文字轉成項目符號、編號行、CSV 或 JSON 陣列。

可以每幾個一組合併嗎?

無法直接做。請先把清單分組,再各組分別合併。

自訂分隔符會被去掉前後空白嗎?

不會,完全照打的內容套上,空格也算,所以「 | 」得到「a | b」、「; 」得到「a; b」。留空的話各行直接相連,中間什麼都沒有。

最後的空行會怎樣?

從試算表貼來的文字常以換行結尾,工具會把它視為最後一個空行。勾選去空行(預設)時會被丟掉;沒勾選的話會多一個尾端分隔符,例如結尾多一個逗號或空格。

本站相關工具

以上步驟全部在這個頁面內完成,合併文字行 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。