Clean Up Text: Remove Extra Spaces, Duplicates, Sort Lines and Change Case
Last updated November 2, 2026
Text copied from PDFs, emails, spreadsheets and websites often arrives messy: double spaces, stray blank lines, repeated entries, random capitals. This guide covers the five clean-up jobs people search for most. Each one shows the quickest free browser tool and how to do the same in Word, Excel, Google Sheets or a code editor. The Uvolix text tools run in your browser; your text is not uploaded.
1. Remove extra spaces and blank lines
Online: paste into Text Cleaner. It turns runs of spaces and tabs into a single space, removes spaces at the start and end of every line, and reduces three or more line breaks to one blank line. Paragraphs stay separate.
- Word: Ctrl+H, find two spaces, replace with one, and repeat Replace All until nothing is found. To remove empty paragraphs, find
^p^pand replace with^p. - Excel / Google Sheets:
=TRIM(A2)removes leading and trailing spaces and leaves single spaces between words.=CLEAN(A2)also strips non-printing characters. Paste the results back as values.
2. Remove duplicate lines
Online: Remove Duplicate Lines keeps the first occurrence of each line and removes later copies. Matching ignores upper/lower case and surrounding spaces, so Apple, apple and apple count as the same line. The original order is kept.
- Excel: select the column, then Data โ Remove Duplicates. Excel matching is not case-sensitive either.
- Google Sheets: Data โ Data cleanup โ Remove duplicates, or
=UNIQUE(A2:A)for a live list. - Notepad++ / VS Code: Edit โ Line Operations in Notepad++; in VS Code, sort first and use an extension or a regular expression.
3. Sort lines alphabetically or by length
Online: Text Sorter sorts lines AโZ, ZโA or shortestโlongest. Sorting follows natural language order, so "apple" and "Apple" sit together, and blank lines are removed.
- Word: select the lines, then Home โ Sort (paragraphs, text, ascending).
- Excel / Sheets: Data โ Sort range, or
=SORT(A2:A)in Sheets. - VS Code: select lines, open the Command Palette and run "Sort Lines Ascending".
4. Find and replace
Online: Find & Replace replaces every occurrence of a word or phrase. Tick Case-sensitive match to replace "Cat" but not "cat". It matches the exact text you type (special characters such as . or * are treated literally), which avoids surprises with symbols.
- Word / Google Docs: Ctrl+H (Docs: Edit โ Find and replace), with "Match case" when needed.
- Excel / Sheets: Ctrl+H, or
=SUBSTITUTE(A2,"old","new")for a formula.
5. Change text case
Online: Case Converter converts to lowercase, UPPERCASE, Title Case or Sentence case. Sentence case lowercases everything, then capitalises the first letter of each sentence, which is useful for text typed with Caps Lock on.
- Word: select text and press Shift+F3 to cycle through cases, or Home โ Change Case (Aa).
- Excel / Sheets:
=UPPER(A2),=LOWER(A2),=PROPER(A2)(title case). - Google Docs: Format โ Text โ Capitalisation.
Automatic title case capitalises every word, including small words such as "and" and "of". Check headlines by hand if you follow a style guide.
A quick clean-up order
- Clean spaces and blank lines first, so duplicates that differ only by spacing match.
- Remove duplicates.
- Sort, if order does not matter.
- Fix case and wording with Case Converter and Find & Replace.
- Check the result with the Word Counter if you have a length limit.
FAQ
Will these tools change my text's meaning?
Only the formatting you ask for. Keep the original until you have checked the result.
Is there a size limit?
No fixed limit; very large texts depend on your device's memory.
Can I remove duplicates but keep case differences?
Not with Remove Duplicate Lines, which ignores case. Use Excel's EXACT function or a code editor for case-sensitive matching.
All text tools are on the text tools page.
Remove extra spaces and normalize blank lines.