Remove Line Breaks, Duplicate Lines and Sort Lines
Free tool to remove line breaks, remove duplicate lines, sort lines and trim whitespace. Markdown-aware so code blocks and lists stay intact.
Copied from a PDF, this paragraph has a hard line break after every sentence fragment, which looks wrong when pasted into a document. Second paragraph. Same problem, different sentence. - item ten - item two - item two ``` keep this code exactly as it is ```
What Does Remove Line Breaks Do?
Remove line breaks joins text that has been hard-wrapped at the end of every line, as happens when you copy from a PDF, an email or a terminal, back into normal flowing paragraphs. The same page bundles the other line tools people reach for at the same time: remove duplicate lines, sort lines, trim spaces, remove empty lines, add line numbers and reverse the order.
All seven operations understand markdown when you want them to, so a README or a set of release notes can be cleaned without merging list items or flattening a code sample.
How to Remove Line Breaks and Clean Up Lines
- Paste the text or open a .txt, .md or .csv file.
- Pick a tab: Remove line breaks, Remove duplicate lines, Sort lines, Trim whitespace, Remove empty lines, Add line numbers or Reverse lines.
- Adjust the options for that tab, for example Keep paragraph breaks or the sort order.
- Copy or download the output. Run a second operation by pasting the result back into the input.
Line Operations Reference
| Operation | Options | Markdown-aware behaviour |
|---|---|---|
| Remove line breaks | Keep paragraph breaks | Code blocks, lists, headings, quotes and tables are not joined |
| Remove duplicate lines | Case-sensitive | Keeps first occurrence; blank lines kept |
| Sort lines | Asc/desc, natural, alphabetical, numeric, length, ignore case | Blank lines dropped |
| Trim whitespace | Collapse multiple spaces | Code indentation and list indentation kept |
| Remove empty lines | — | Whitespace-only lines count as empty |
| Add line numbers | Separator, skip blank lines | Numbers padded to equal width |
| Reverse lines | — | Last line first |
Remove Extra Spaces, Duplicate Lines and Sort Lines Safely
A line break remover that ignores structure will turn “- item one” and “- item two” into one line, and will flatten the indentation in a code sample. The Markdown-aware toggle avoids both: fenced blocks are copied through untouched, and any line that starts with a list marker, heading, quote or table pipe is treated as its own unit.
To remove extra spaces without changing meaning, the trim tab collapses runs of spaces and tabs inside a line but keeps the indentation before a nested list item. Sorting drops blank lines because an empty line has no sensible position in a sorted list; dedupe keeps them because they usually mark paragraphs.
Why Use This Remove Line Breaks Tool
Cleaning pasted text is usually three or four small steps, and switching between separate websites for each one is slower than switching tabs on one page. Every operation here runs instantly in your browser as you change an option, nothing is uploaded, and the input and output line counts are shown so you can see what a step did. Use the case converter linked below when the text also needs its capitalisation fixed after you remove line breaks.
Frequently Asked Questions
How do I remove line breaks from text?
Paste the text, keep the Remove line breaks tab selected and copy the output. Lines inside a paragraph are joined with a space; with Keep paragraph breaks on, blank lines still separate paragraphs. To remove line breaks completely and get one long line, turn that option off.
Will it break my markdown?
Not with Markdown-aware on. Fenced code blocks are left untouched, list items, headings, quotes and table rows stay on their own lines, and only wrapped prose is joined. Turn the option off for plain text where every line should be merged.
How does remove duplicate lines decide what is a duplicate?
Two lines are duplicates when they are identical after trimming spaces at the ends; the first occurrence is kept and later ones are removed. Turn Case-sensitive off to treat “Apple” and “apple” as the same line. Blank lines are never removed by this tab.
What is the difference between natural and alphabetical sort lines?
Natural sort understands numbers inside text, so file2 comes before file10. Alphabetical sort compares character by character, which puts file10 first. Numeric sort orders by the first number in each line, and length sort by the number of characters.
Does trim whitespace touch code blocks?
No. With Markdown-aware on, indentation inside fenced code is kept. Outside code, leading and trailing spaces are trimmed, runs of spaces collapse to one, and three or more blank lines collapse to one.