Cleaning Messy Copied Text: Spacing, Duplicates and Case
What the text cleaner, duplicate remover, sorter and case converter really do, with a step-by-step cleanup order and their limits.
Explore free tools →What the text cleaner, duplicate remover, sorter and case converter really do, with a step-by-step cleanup order and their limits.
Explore free tools →Text rarely survives a copy and paste unchanged. A PDF stores each line as a separate fragment, so pasted paragraphs break in the middle of sentences. A web page carries spacing that was meant for layout. An email thread adds indents. A spreadsheet export repeats rows. Typing with caps lock on gives you a paragraph you must retype. None of this is difficult to fix, but doing it by hand is slow and easy to get half right.
This guide walks through the text tools on Doc Writer Lab that handle these jobs and, just as importantly, explains what each one does and does not do. The precise behaviour matters, because a cleanup tool that quietly removes something you wanted is worse than no tool at all.
Look at the text before you choose a tool. Most problems fall into four groups.
Fix them in that order. Cleaning spaces first makes the later steps more predictable, because two lines that differ only by a trailing space are not seen as identical until the spacing is tidied.
The Text Cleaner has three actions and you press the one you want. They are separate on purpose, so apply them one at a time and read the result.
This collapses any run of two or more spaces or tabs into a single space, then removes spaces from the very start and end of the whole text. It does not touch line breaks. Two details to know: it only recognises ordinary spaces and tabs, so the non-breaking spaces that some web pages and word processors insert may survive. Indented lines are reduced to a single leading space rather than none, so use the next action to remove indentation entirely.
This removes whitespace from the beginning and end of every line while keeping the lines themselves, including empty ones. It is the right choice for text with ragged indents, such as quoted email replies or lines copied from a table.
This deletes every line that is empty or contains only whitespace. Be careful here: it removes the paragraph gaps too, so a document with a blank line between paragraphs will become one solid block. For a plain list, that is exactly what you want. For an essay, probably not, so use it only on lists and data.
Text Cleaner does not join broken lines back into paragraphs, and it does not strip formatting, links or hidden characters beyond the spacing described. If a PDF paste breaks every line mid-sentence, you will need to rejoin the lines yourself, or use Find & Replace to swap in a space where you can recognise a pattern. Note that Find & Replace matches exactly what you type, including capital letters, and replaces every occurrence, so check the preview before copying.
The Remove Duplicate Lines tool keeps the first appearance of each line and drops later repeats, in the original order. How it decides that two lines are the same is the part to understand:
That behaviour is ideal for email lists, keyword lists, URLs and names. It is a poor fit where capitalisation carries meaning, such as a list of case-sensitive codes or file names on a system that distinguishes them. In that case, check the output count against what you expect before relying on it. It also compares whole lines only. red shoes and red shoes size 9 are different lines, and two entries with different punctuation are different too.
After removing repeats you can put the list in order with Sort Lines, which sorts A to Z or Z to A using the browser's locale-aware comparison, or reverses the existing order. Sorting is a good last step because it makes remaining near-duplicates, such as small spelling variants, sit next to each other where you can see them.
The Case Converter offers UPPERCASE, lowercase, Title Case and Sentence case. The simple ones are exactly what they sound like. The last two deserve a closer look because both begin by turning everything to lowercase.
The practical advice is to convert, then proofread the result with those two weaknesses in mind. For text that has to follow a specific style guide, treat the tool as a quick first pass.
Suppose you copied a mailing list from three sources into one box and it looks like this: some names have extra spaces, some are in capitals, and a few repeat. Here is a sensible sequence.
Each step is a deliberate pause point. If a tool did something unexpected, you see it immediately rather than three steps later.
The tool lowercases the whole text before capitalising each word, so any existing capitals are lost. Fix acronyms by hand afterwards.
No. The first occurrence of each line stays where it was.
Not with these tools. They work on whole lines. Put one word per line first if you want to deduplicate words.
It will tidy spaces and blank lines, but it will not rejoin lines broken mid-sentence. For PDF source material, see the guide on extracting text from a PDF.