U.UtilityApp
✍️ TextFree · No signup

Remove Duplicate Words

Delete repeated words from your text while keeping the first occurrence.

How it decides two words are the same

The text is split wherever there is a space, tab or line break, and each piece between them is a word. A word is removed if the same piece, ignoring capitals, has already appeared anywhere earlier in the text. The first occurrence always stays.

Two details follow from that:

  • Capitals don't matter. The is a repeat of the.
  • Punctuation does. A comma or full stop attached to a word makes it a different piece, so red, and red are not duplicates.
InputOutput
the the cat sat on the mat The endthe cat sat on mat end
red, green, red, blue, Redred, green, blue, Red

In the second row, the second red, goes, but Red stays because it has no comma.

The gaps it leaves behind

A removed word takes nothing else with it. The spaces on both sides stay, so you get double spaces wherever a word was deleted. The first row above actually comes out as the, two spaces, cat sat on, two spaces, mat, two spaces, end. If the last word of your text is removed, a trailing space is left.

Run the result through Remove Extra Spaces to close the gaps. Line breaks are also kept, so a line can end up shorter, or even empty if every word on it was a repeat.

It works across the whole text, not per line

A word only survives the first time it appears in the entire text. If you paste a list of phrases, one per line, a word repeated on a later line is removed from that line:

apple banana apple cherry banana date

becomes apple banana, then cherry, then date, each still on its own line but with a leading space where the removed word was. If you want to remove whole repeated lines instead, use Remove Duplicate Lines. If you want repeats removed only within each line, run the lines through one at a time.

Where it helps and where it doesn't

It is good for comma-free tag and keyword lists, hashtag lists, and text where a word got doubled by a copy-paste slip, such as the the.

It is a poor fit for normal sentences. Ordinary prose repeats words like the, and and to constantly, so after the first sentence most of them are gone and the text stops making sense. To find accidental doubled words in an essay, search for them instead of removing every repeat.

Frequently asked questions

How do I make it ignore punctuation?+

Run the text through Remove Punctuation first, so that red, and red become the same word. Be aware that this also removes apostrophes and hyphens from the words you keep.

Can I make it case-sensitive?+

No. Apple and apple are always treated as the same word, and whichever comes first is the one kept, with its original capitals.

Does it count hyphenated words as one?+

Yes. A hyphen doesn't split a word, so well-known is one word and is only a repeat of another well-known. It is not a repeat of well or known on their own.

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/text/remove-duplicate-words" title="Remove Duplicate Words" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/text/remove-duplicate-words">Remove Duplicate Words</a> by UtilityApp</p>