Multiline to Single Line Converter
TX-49Paste text that runs over several lines and join it into one line with the separator you choose, or keep every character and turn each line break into the two characters backslash and n.
Runs in your browser. Nothing is uploaded.
Multi-line text
Single line
How to use it
- Paste your multiline text into the input box.
- Pick the separator to put between lines: a space, nothing, a comma, a semicolon, a pipe or a tab.
- Press Join into one line. Empty lines are dropped and each line is trimmed unless you untick that option.
- Press Escape line breaks as \n instead if you need one line that still holds the original breaks, for example inside a string.
Joining lines
Join into one line removes empty lines, trims each remaining line if you leave that ticked, and puts your separator between lines. Because empty lines are dropped first, a comma separator never gives you two commas in a row. A space is the usual choice for wrapped paragraphs or a multi-line SQL query, a comma suits a list of values, and nothing at all suits wrapped codes or tokens that were split across lines. The line break at the end of the text is dropped.
Escaping instead of joining
Escape line breaks keeps every character, including empty lines and indentation, and replaces each line break with the two characters \n, or \r\n for a Windows break. That is handy for pasting text into a one-line string, a config value or a test case. It does not escape quotes. If the text itself contains backslashes and you want to turn the result back later, tick Double backslashes first so a literal backslash cannot be confused with an escape.
Related tools
To keep paragraphs apart while joining the lines inside each one, use the Remove Line Breaks tool, which has a Keep paragraph breaks option. To build a quoted string for a programming language, with quotes escaped, use the String Builder. To clean up repeated spaces after joining, the Remove Extra Spaces tool collapses them.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Paste the lines to join into one line. | The input box is empty or holds only whitespace. | Paste the multiline text you want to join. |
Questions people ask
How do I convert multiple lines to a single line?
Paste the text, choose a separator and press Join into one line. Lines are trimmed and empty lines are dropped, then the rest are joined with your separator. Copy the single line or download it.
How do I replace line breaks with a space?
Leave the separator on A space and press Join into one line. Every line break becomes a single space, and empty lines are removed so you do not get double spaces.
How do I turn a list into one comma separated line?
Paste the list, one item per line, choose A comma or A comma and a space as the separator and press Join into one line. Empty lines are skipped, so there are no stray commas.
How can I keep the line breaks but write them as \n?
Press Escape line breaks as \n. Each line break becomes a backslash and an n, and everything else is kept as typed, including empty lines and indentation.
Does it work with Windows line endings?
Yes. Windows, Unix and old Mac line endings are all recognised when joining. When escaping, a Windows break is written as \r\n and the others as \n or \r.
About this tool
Join into one line drops empty lines, optionally trims each remaining line, and puts your separator between them, so a comma separator never produces two commas in a row. Escape line breaks keeps every character, including empty lines, and replaces each line break with the two characters \n (or \r\n for a Windows line break), which is useful for pasting multi-line text into a one-line string or a JSON-style value. It does not escape quotes; with the backslash option on it only doubles backslashes so the result can be turned back. The final line break at the end of the text is dropped. For a paragraph-aware version, use the Remove Line Breaks tool. Nothing is uploaded.