A little help goes a long way. Find a tool/

Text FIELD NOTES · 4 MIN READ

Joining Text: Turning a List Into One String

The split-clean-join pipeline: lines or words in, trim and dedupe, then one separator-glued string ready for CSV rows, tag fields, and SQL lists.

A column of values is the easiest thing in the world to produce and one of the hardest to use. Spreadsheets, log files, and copy-pasted lists all hand you data one item per line — but CSV rows, SQL queries, tag strings, and URLs want everything on one line, with a character between each pair. The bridge between those two worlds is the join: split into items, clean each one, and glue them back together with a separator. It is the inverse of splitting, and it is where most copy-paste chores actually end.

Split, clean, join

Every join starts with a split. A text joiner offers two views of the same input: split on line breaks, so each line becomes one item, or split on whitespace, so each word becomes one item. Then comes the quiet, load-bearing step — every item is trimmed of surrounding whitespace and empty items are dropped. That step is what makes the tool forgiving: paste a list with trailing spaces, blank lines in the middle, or a stray tab, and none of it leaks into the output.

input (lines):      input (words):
  apple             one two  three
  banana
  apple

items: ['apple',     items: ['one', 'two', 'three']
        'banana',
        'apple']

The word view is stricter about what an item is — any whitespace run is a boundary, so one two  three is three items, not two. The line view respects your line structure and only trims the edges. Choosing between them is choosing what a "value" means in your data.

The separator does the real work

The separator is the personality of the output. A comma followed by space turns a list into readable prose; a bare comma makes CSV; a semicolon with space suits prose lists that already contain commas; a pipe or dash makes human-skimmable tables; a space produces a tag string; a newline splits — in effect re-formatting the list with a different rhythm. Built-in presets cover the common cases, and a custom field accepts anything, including multi-character separators like | or a literal newline.

['apple', 'banana', 'apple']
join ', '    -> apple, banana, apple
join ','     -> apple,banana,apple
join ' '     -> apple banana apple

One boundary worth knowing: the tool inserts the separator between items and nothing else. It does not wrap items in quotes or brackets. If you need 'apple','banana','apple' for a SQL IN clause, join with a comma first and then add the quotes — the Find and Replace Text tool does that in one pass.

Dedupe before you join

Lists assembled by hand or by copy-paste accumulate duplicates, and a joined string inherits every one of them. The remove-duplicates option keeps only the first occurrence of each item, preserving original order — which matters when the order is meaningful:

apple / banana / apple
dedupe off -> apple, banana, apple   (3 items)
dedupe on  -> apple, banana          (2 items)

Deduplication happens during the join, not as a separate pass, which is convenient — but it is a different job from the Remove Duplicate Lines tool, which strips repeats while keeping your line structure intact. If the output should still be a multi-line list, use that tool; if the output should be one string, dedupe here.

Where joins end up

The joined string is rarely the destination; it is the format some other system demanded. Turning a spreadsheet column into a CSV row. Building tag1,tag2,tag3 for a form field or a URL parameter. Assembling a single-line summary from meeting notes. Producing the comma-separated value list that a query or a config file wants. In each case the mental model is the same — items, separator, and optionally a dedupe — and once you see the model, the tool is a two-click affair. The sibling operations live nearby: sorting the items first with the Line Sorter, or the whole split-sort-join pipeline described in Find & Replace, Line Sorting, and Joining Text.

Try it yourself

Paste apple / banana / apple (one per line) into the Text Joiner and join with , to get a clean three-item string. Toggle remove-duplicates and watch it become two. Then switch the split mode from lines to words, type a custom separator like | , and see how the same input produces a completely different shape of output.

Frequently asked questions

How is Text Joiner different from Remove Duplicate Lines?
Remove Duplicate Lines strips repeats while keeping your line structure intact. Text Joiner merges everything into a single string with a separator between items, and can remove duplicates along the way. If the output should still be a multi-line list, use Remove Duplicate Lines; if it should be one string, use Text Joiner.
Can I join with a custom separator?
Yes. Beyond the built-in presets (comma, comma-space, semicolon, pipe, dash, space, newline) the custom field accepts any string, including multi-character ones like " | " or a literal newline.
Does it trim items and drop empty ones?
Always. Every line or word is trimmed of surrounding whitespace and empty items are discarded, so blank lines and stray spacing in the input never leak into the joined result.
Can I get quoted values for a SQL IN list?
The tool inserts the separator between items and nothing else — it does not wrap items in quotes. Join with a comma first, then add the quotes in one pass with the Find and Replace Text tool.
Should I split on lines or on words?
Split on lines when each line is one value — a spreadsheet column, a list of names. Split on words when whitespace defines the items, such as turning a sentence into a tag string. The choice defines what counts as one item.