Home / Guides / Cleaning Messy Copied Text: Spacing, Duplicates and Case
Free guide · Doc Writer Lab

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 →

Why copied text arrives messy

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.

Start by deciding what is wrong

Look at the text before you choose a tool. Most problems fall into four groups.

  • Spacing: double spaces, stray tabs, trailing spaces at the end of lines.
  • Line breaks: blank lines everywhere, or lines broken mid-sentence.
  • Repeats: the same item appearing several times in a list.
  • Capitalisation: all capitals, no capitals or inconsistent headings.

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.

Fixing spaces and blank lines with Text Cleaner

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.

Fix spaces

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.

Trim lines

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.

Remove blank lines

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.

What it does not do

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.

Removing duplicates from a list

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:

  • It ignores capital letters, so Apple, apple and APPLE are treated as the same line.
  • It ignores spaces at the start and end of a line when comparing.
  • It removes empty lines from the result, so you get a compact list even if the input had gaps.
  • The line it keeps is the first one, exactly as you typed it, not a lowercased copy.

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.

Changing case with Case Converter

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.

  • Title Case capitalises the first letter of every word. It does not know style rules, so small words such as of, the and and are capitalised too, which many style guides would not do. It also lowercases everything else first, so acronyms like PDF or NASA become Pdf and Nasa. Word-parts after a hyphen are not capitalised.
  • Sentence case capitalises the first letter of the text and the first letter after a full stop, question mark or exclamation mark. Proper names and the word I are lowercased and will need fixing by hand. An abbreviation followed by a full stop can trigger a capital where you do not want one.

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.

A worked example

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.

  1. Paste the list into Text Cleaner and press Trim lines, then Remove blank lines. Copy the result.
  2. Paste that into Remove Duplicate Lines. Entries that differed only by capitals or edge spaces collapse into one.
  3. Paste the unique list into Sort Lines and choose A to Z.
  4. If the names should be in a consistent style, finish in Case Converter with Title Case and read it over for names such as McDonald, which will come out as Mcdonald.

Each step is a deliberate pause point. If a tool did something unexpected, you see it immediately rather than three steps later.

Habits that save you trouble

  • Keep the original text somewhere until you have checked the cleaned version. The tools do not offer an undo across tools.
  • Check counts. The Line Counter shows how many lines you had before and after, which is a quick sanity check for deduplication.
  • Do not clean data that contains meaningful blank lines, such as poetry, code or a script, without looking at the result first.
  • Work in small chunks if a browser tab slows down on very large pastes.
  • Text stays in your browser while you work, but do not paste passwords or other secrets into any web page more than you must.

Frequently asked questions

Why did Title Case turn my acronym into lowercase letters?

The tool lowercases the whole text before capitalising each word, so any existing capitals are lost. Fix acronyms by hand afterwards.

Does removing duplicates change the order?

No. The first occurrence of each line stays where it was.

Can I remove duplicate words, not lines?

Not with these tools. They work on whole lines. Put one word per line first if you want to deduplicate words.

Will it fix text pasted from a PDF?

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.