Text Transform

Remove duplicate words

What to do

Transformed in your browser · nothing is uploaded

Local · first occurrence kept
Advertisement
320 × 100

Keeps the first occurrence of each word and drops the rest, leaving the survivors in their original order. Words are compared without case, so "The" and "the" count as one. The second option does the same job on whole lines, and that is the one to use for data.

How to use the remove duplicate words

1 Paste the text, or the list, into the first box.
2 Choose words for prose, lines for a column of values.
3 Read the result; the first of each repeat is the one kept.
4 Copy it out.

The two options differ in more than their unit. De-duplicating words splits on whitespace and rejoins with single spaces, so line breaks and indentation do not survive it — a tidy list goes in and one long line comes out. De-duplicating lines leaves each surviving line exactly as it was, indentation included, and compares them after trimming: apple, apple and apple count as one line and only the first survives. Case is where they part company. Words are folded, lines are not, so Apple and apple are one word and two lines. That is deliberate. An identifier, a filename or the part of an email address before the @ can differ by case and mean something else, so lowercase the list first with the case converter if you do want them folded.

Punctuation travels with the word, which means cat and cat, are two different tokens and both survive; run the text through the cleaner first if that is a problem. And note what this does not tell you: it removes repeats without reporting them. If the question is how often each word appeared rather than what the unique set is, the word counter has a keyword frequency list. Order is preserved rather than sorted, so sort the result afterwards if you want both.

Questions

The first, so the order you had is the order you keep.

MDN, working with strings
Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding