Join Text
Join multiple lines into a single string with a delimiter
100% client-side processing
Elements: 3
Elements: 0 (empty removed: 0)
Text rarely arrives in the shape you need. Spreadsheets emit comma-separated rows, your code wants one value per line, and pasted lists carry invisible trailing spaces. This join and split tool converts between a single delimited string and a list of lines in one step. Everything runs locally in your browser, so pasted data does not leave the page.
How to Use
- Paste your text into the input box.
- Choose join (lines into one string) or split (one string into lines).
- Pick a preset delimiter (comma, space, newline, tab, semicolon, pipe, colon) or select Custom and type your own, including multi-character strings.
- Optionally enable Trim to strip leading and trailing whitespace from each element, and Remove empty to drop blank items.
- Copy the result with the copy button, or press Swap to reverse the direction.
Worked Examples
Joining lines. Input with three lines apple, banana, cherry and the comma preset produces apple,banana,cherry. The element count reads 3.
Splitting with cleanup. Input red, green,blue , with the comma preset, Trim on, and Remove empty on. The string splits into four pieces: red, green, blue , and an empty piece after the trailing comma. Trim fixes the two padded values, Remove empty drops the blank, and the output is three lines: red, green, blue. The counter reports 3 elements and 1 empty item removed.
Splitting without cleanup. The same input with both options off yields red, green, and blue with their leading spaces intact, plus a blank line, because the raw pieces are written straight back out.
What Happens to Whitespace and Empty Items
Both directions run the same cleanup pipeline. Trim is applied to every element first; Remove empty then filters out anything whose length is zero. Order matters: a field containing only spaces is not empty until Trim runs, so enabling both is what clears whitespace-only values. In join mode the input is divided on the line-feed character; in split mode the delimiter is escaped and used to divide the text. The delimiter itself is discarded during a split, so if you need to reconstruct the original string exactly, use Swap to rejoin with the same delimiter.
Choosing the Right Delimiter
| Delimiter | Good for | Watch out for |
|---|---|---|
| Comma | CSV-style rows, quick arrays | Values that contain commas |
| Tab | Spreadsheet paste, TSV exports | Editors that convert tabs to spaces |
| Pipe | Text where commas are common | Markdown table syntax |
| Semicolon | European CSV files | Mixed with commas in one file |
| Newline | Restoring a list, joining one-value-per-line output | Joining makes the output multi-line |
| Space | Turning a sentence into words | Quoted phrases lose their grouping |
A custom delimiter is helpful when your data uses something unusual such as ::, ||, or a word like AND. Because custom input is matched literally, it can include characters that would otherwise have special meaning.
Practical Patterns
Building a SQL IN list from a column. Copy the values from a spreadsheet, split on the newline or comma preset with Trim and Remove empty enabled, then swap to join on the same delimiter. You end up with a tight value list, though you still need to add quotes and parentheses around it yourself.
Turning a sentence into words. Split on the space preset with Remove empty on. Punctuation stays attached to each word, so follow with a cleaning step if you need bare words.
Reformatting a list between tools. YAML accepts a comma-separated flow sequence while a shell script often wants one value per line. Split on comma, copy the lines, and paste them into the target file.
Checking a count before you commit. The input and output counters show how many items the tool actually saw. If a join produces more elements than expected, the input usually contains more line breaks than you realized, which is common when pasting from a rich-text editor.
Common Mistakes
Splitting a CSV line that uses quotes. Delimiters inside quoted fields are still treated as separators, so the column count comes out too high. Use a CSV parser when quoting is involved.
Assuming join adds quotes or escaping. It inserts the delimiter only. Building a SQL IN list or a JSON array from the output means adding quotes or brackets yourself.
Leaving Trim off with pasted data. Spaces that look harmless break exact-match lookups and cause duplicate-looking list entries.
Choosing a delimiter that appears in the values. If a field can contain a comma, split on a pipe or tab instead. The safest delimiter is one that appears nowhere in the data.
Forgetting that split and join are inverse only when the cleanup options match. Splitting a string that contains a trailing delimiter and rejoining it will drop the empty final element if Remove empty is on.
Limits and Edge Cases
The delimiter is always literal, never a regular expression, so patterns and character classes cannot be used to split. Multi-character delimiters work, but overlapping ones do not. Empty input splits into a single empty element before cleanup; with Remove empty on it becomes zero lines. Text pasted from Windows keeps carriage returns unless Trim is enabled. Neither mode sorts, deduplicates, or modifies case, so pair this tool with sorting or deduplication when a list needs more than reformatting.
Related Tools
Frequently Asked Questions
Does splitting treat my delimiter as a regular expression?
No. The delimiter is escaped before use, so characters like dot, pipe, asterisk, and plus are matched literally. Entering | splits only on pipe characters, not on the regex alternation operator.
Why did my quoted CSV line split into too many columns?
This tool splits on raw delimiter characters and does not understand CSV quoting. A line like Doe, "John, Jr." contains three commas, so it becomes three lines even though the middle comma is inside quotes. Handle quoted CSV with a dedicated parser instead.
What happens to Windows CRLF line endings when I join lines?
Joining splits the input on the line-feed character only, leaving a trailing carriage return on each line. Turning on Trim removes that stray CR, which is why trim is recommended for text copied from Windows or from CSV exports.
Can I build a quoted SQL IN list with the join mode?
Not directly. Join inserts the delimiter between values but does not add quotes or escape anything, so red,green,blue becomes red,green,blue. Add the quotes in a second pass or wrap each value before pasting.
How is the element count calculated in each mode?
In join mode the count is the number of input lines after trimming and empty-item removal. In split mode it is the number of pieces produced by the delimiter, after the same cleanup. The count shown under the output is the number of elements in the result.
What does the Swap button do exactly?
Swap flips the mode and exchanges the input and output boxes. If you joined three lines into one comma-separated string, Swap puts that string in the input, switches to split mode, and immediately breaks it back into the original three lines.
Reviewed by the HandyTools Hub team · Last updated