LineBreaks

Join lines with a separator

A column of values goes in; one delimited line comes out. This is a different job from removing line breaks — the separator matters, the blank lines have to go, and the values often need quoting for wherever they are going next.

Lines become a single delimited list, ready for a formula or a query.

8 lines · 111 characters · 14 wordsLF ×71 line ends in whitespace
1 line · 112 characters+1 characters

Eight lines including a blank one, one with an apostrophe, one with double quotes and one padded with spaces.

Eight separators over the same awkward list

The list used throughout this page is deliberately not clean. It has 8 lines: 1 of them blank, 1 padded with spaces, one containing an apostrophe and one containing double quotes. Those are precisely the four things that break a naive join, so the rows below are tests that can fail. None of them is a demonstration.

Generated at build time by running the tool with each preset on the sample list. → is a tab, · a space. Every output has 7 items — the blank line is dropped.
SeparatorWhat it is forResult
Comma + space Prose, or a quick list to paste into an email. Ada·Lovelace,·O'Neill,·Grace·Hopper,·Katherine·Johnson,·Radia·"Radia"·Perlman,·Margaret·Hamilton,·Barbara·Liskov
112 characters
Comma, no space A CSV row, or a value for a spreadsheet formula. Ada·Lovelace,O'Neill,Grace·Hopper,Katherine·Johnson,Radia·"Radia"·Perlman,Margaret·Hamilton,Barbara·Liskov
106 characters
Single space Command-line arguments, or turning a column back into a sentence. Ada·Lovelace·O'Neill·Grace·Hopper·Katherine·Johnson·Radia·"Radia"·Perlman·Margaret·Hamilton·Barbara·Liskov
106 characters
Pipe A regex alternation, or a log format that already uses commas. Ada·Lovelace|O'Neill|Grace·Hopper|Katherine·Johnson|Radia·"Radia"·Perlman|Margaret·Hamilton|Barbara·Liskov
106 characters
Tab Pasting a column across a spreadsheet row. Ada·Lovelace→O'Neill→Grace·Hopper→Katherine·Johnson→Radia·"Radia"·Perlman→Margaret·Hamilton→Barbara·Liskov
106 characters
Semicolon + space Email address fields in Outlook, and locales where CSV uses semicolons. Ada·Lovelace;·O'Neill;·Grace·Hopper;·Katherine·Johnson;·Radia·"Radia"·Perlman;·Margaret·Hamilton;·Barbara·Liskov
112 characters
SQL IN () list A WHERE … IN clause. Apostrophes are doubled, so O'Neill survives. 'Ada·Lovelace',·'O''Neill',·'Grace·Hopper',·'Katherine·Johnson',·'Radia·"Radia"·Perlman',·'Margaret·Hamilton',·'Barbara·Liskov'
127 characters · machine-checked: passes
JSON array elements A JSON array body. Double quotes and backslashes are escaped. "Ada·Lovelace",·"O'Neill",·"Grace·Hopper",·"Katherine·Johnson",·"Radia·\"Radia\"·Perlman",·"Margaret·Hamilton",·"Barbara·Liskov"
128 characters · machine-checked: passes

Every one of the 8 outputs still contains the apostrophe from O'Neill intact or correctly escaped: true. That is asserted rather than eyeballed, because an apostrophe silently eaten by a quoting routine is the classic way a name list corrupts a database import.

The two outputs that are checked, not just shown

Six of the presets produce plain text that can only be inspected. Two produce a format with rules, so this build checks them instead of asserting them — 2 of 2 passed.

JSON

The JSON preset wraps each value in double quotes and escapes backslashes and quotes inside it. The check is a parse: the output is wrapped in square brackets and handed to JSON.parse, and the result must be an array of exactly 7 elements. For the sample list that gives:

["Ada Lovelace", "O'Neill", "Grace Hopper", "Katherine Johnson", "Radia \"Radia\" Perlman", "Margaret Hamilton", "Barbara Liskov"]

Note what happened to Radia "Radia" Perlman. The inner double quotes became \", which is what makes the array parse. A join that simply wrapped each line in quotes would have produced invalid JSON at that row and valid JSON everywhere else — the worst possible failure mode, because it works on your test data.

SQL

The SQL preset wraps each value in single quotes and doubles any apostrophe inside it, which is the escape the SQL standard specifies. For the sample list:

SELECT * FROM people WHERE name IN ('Ada Lovelace', 'O''Neill', 'Grace Hopper', 'Katherine Johnson', 'Radia "Radia" Perlman', 'Margaret Hamilton', 'Barbara Liskov');

O'Neill comes out as 'O''Neill'. Without that doubling the apostrophe would close the string literal early and the rest of the value would be parsed as SQL — which is not merely a broken query but the shape of an injection bug.

What the check does and does not prove. There is no SQL engine in this build, so the SQL row is checked by counting quote characters for balance, not by executing it. That is a weaker guarantee than the JSON parse, and it is stated here in as many words. Escaping for a specific database — identifiers, backslash handling in MySQL, and anything user-supplied — is a job for that database's own parameter binding, not for a text tool. Use this to build a hand-run query, not to assemble SQL in production code.

Why blank lines are dropped by default

A blank line in a pasted column is almost always an artefact — the row after the last one, or a gap in a spreadsheet selection. Keeping it produces a, , b, which is a three-element list containing one empty string, and every consumer treats that differently. Dropping it produces a, b. The sample here has 1 blank line and comes out with 7 items rather than 8.

If the empty positions carry meaning — a fixed-length column where row 4 is genuinely blank — switch the option off and the gaps are preserved as empty items.

Trimming, and why it happens before the join

Values pasted out of a spreadsheet frequently carry leading or trailing spaces. Joined without trimming, ' Margaret Hamilton ' becomes a value with invisible padding that will not match anything, and in a SQL list it becomes an entry that silently returns no rows. Every line is trimmed of leading and trailing spaces and tabs before the separator is applied, and interior runs of spaces are collapsed to one.

No-break spaces are the exception, and deliberately so: they are content until you say otherwise. If a value came out of a word processor and will not match, press Show invisible characters — an NBSP badge at the edge of a value explains it — then switch on the no-break space conversion.

Related jobs

To turn one delimited line back into a column, or to strip breaks from inside spreadsheet cells without destroying the rows, see the CSV page. To clean the column before joining it — blank lines, padding, stray no-break spaces — remove blank lines and tidy the spaces first; the two operations compose cleanly in that order.

Joining a column, and what goes wrong

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

Paste it above. Join lines mode is already selected and the separator is already a comma and a space. Blank lines are dropped and each line is trimmed before joining, so a column pasted out of a spreadsheet comes out clean.

How do I build a SQL IN clause from a list?

Set "Wrap each line" to SQL. Each value is wrapped in single quotes and every apostrophe inside it is doubled, which is the escape SQL actually specifies — so O'Neill becomes 'O''Neill' and the query survives it. The full output for the sample list is in the table below.

Will it escape quotes for JSON?

Yes. The JSON setting wraps each line in double quotes and escapes backslashes and double quotes inside it. The result below was checked by parsing it: wrapping the output in square brackets and running it through JSON.parse yields an array of the right length.

Why did my blank lines disappear?

Because a blank line in a list is not an item, and Drop blank lines before joining is on by default. Switch it off and the empty positions come back as empty items between separators. The section below on why they are dropped has the counts for the sample list.

Can I join with a tab so it pastes across a spreadsheet row?

Yes — pick Tab as the separator. A tab-separated single line pasted into a spreadsheet spreads across the columns of one row, which is the inverse of copying a column down.

Can I go the other way, splitting a list back into lines?

Not on this page — but choosing "New line" as the separator in Join lines mode is the identity operation, which is occasionally the tidiest way to normalise a mixed-ending list into one clean column. For proper ending conversion use convert line endings.

After the list is one line

  • the line break remover with all six modes — join is one of six modes there, which is useful when the column needs cleaning up before it is worth joining at all.
  • Remove line breaks in Excel and CSV — why a CSV has two kinds of line break that look identical, and how to strip one without destroying the other.
  • Remove blank lines — eleven candidate lines and three definitions of "blank" that disagree about nine of them.
  • Remove extra spaces — all twenty invisible horizontal characters, and the one that an ordinary space-collapsing regex can see.
  • Word Counter — the other half of the tidy-up job: word, character and reading-time counts once the text is one paragraph again.
  • Case Converter — text pasted out of a PDF often arrives SHOUTING as well as broken — this fixes the capitalisation under four style guides.