If you're looking for online tools that already do this then check out these tools:
Types of Text Line Breaks
Line breaks in text are generally represented in three ways as either \r\n or as \n or \r. The first type of line break (\r\n) is usually created on a windows computer, the second (\n) on Linux and the third kind of line break (\r) on an Apple computer.
In order to remove line breaks from text we must deal with all three types of line breaks as typically your text could come from any of those sources.
//We define the text variable that needs to be cleansed of line breaks.
someText = someText.replace(/(\r\n|\n|\r)/gm,"");
The "gm" at the end of the regex statement signifies that the replacement should take place over many lines (m) and that it should happen more than once (g).
If for instance we got a column of text from a pdf and we just removed the line breaks entirely we might wind up with words and sentences that run together and are hard to read like this:
Here is a sentence.This sentence runs into itand unfortunately we aremissing some spaces.
Which of course should read like this instead:
Here is a sentence. This sentence runs into it and unfortunately we are missing some spaces.
In order to do this we will update our example by replacing all the types of line breaks with a single space like so:
someText = someText.replace(/(\r\n|\n|\r)/gm," ");
Removing Extra Spaces from Lines
//Replace all double white spaces with single spaces
someText = someText.replace(/\s+/g," ");
Remove Line Breaks Example