U.UtilityApp
✍️ TextFree · No signup

Text to One Line Converter

Flatten multi-line text into a single line — handy for CSV cells, code and copy-paste.

What happens at each line break

Every line break is replaced with a single space, together with any spaces or tabs on either side of it. Then any remaining run of two or more spaces or tabs is squeezed to one space, and spaces at the very start and end are trimmed. The result is one line with exactly one space wherever a break used to be.

A real run:

Line one Line two (two trailing spaces) (3 spaces)Line three New paragraph

becomes Line one Line two Line three New paragraph. Note that the blank line before the last paragraph disappears too: paragraph breaks are not kept, and the paragraphs simply run on.

Pasting into a spreadsheet cell or CSV field

Multi-line text pasted into a spreadsheet usually spreads over several rows, and a line break inside a CSV field breaks the file for many importers unless the field is quoted. Flattening the text first avoids both problems.

One thing to check: a single tab between two words in the middle of a line is kept. In a spreadsheet, a tab moves the rest of the text into the next column, so if your text came from a table, replace the tabs with spaces before you paste. Tabs at the start or end of a line are removed along with the line break.

SQL, commands and code

Flattening is handy for a long query you want to paste into a single-line field, a log search box or a terminal history:

SELECT id, (7 spaces)name FROM users WHERE active = 1;

becomes SELECT id, name FROM users WHERE active = 1;

Be careful with code where line breaks carry meaning. A -- or // comment in the middle turns everything after it into a comment once the lines are joined. Languages that end statements at line breaks, such as Python or shell scripts, also break. SQL and JSON are safe because they ignore line breaks between tokens.

Words split by a hyphen at the line end

Text copied from a PDF or a narrow column often has words broken across lines with a hyphen. Joining keeps the hyphen and adds a space, so hy- at the end of one line and phen at the start of the next become hy- phen. Search the result for a hyphen followed by a space and repair those words by hand. Don't replace every hyphen-space automatically, because real dashes written as a spaced hyphen would be joined too.

Frequently asked questions

Can I join the lines with a comma instead of a space?+

Not directly. Join the lines here first, then use Find and Replace to turn each space into a comma. That only works when the lines themselves contain no spaces, such as a list of IDs or single words.

Is there a length limit on the line?+

The tool itself sets none, and the result is one line however long the input. The place you paste it into may have its own limit, such as a field's maximum length.

What happens to Windows line breaks?+

They are joined like any other. The browser stores line breaks from a Windows file as plain line feeds when you paste, and stray carriage returns would be swept up with the surrounding whitespace anyway, so no hidden characters are left in the line.

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/text/text-to-one-line" title="Text to One Line Converter" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/text/text-to-one-line">Text to One Line Converter</a> by UtilityApp</p>