How to Remove Duplicates Within a Cell in Google Sheets: Comma-Separated Lists, Tags, Line Breaks and Letter Case (2026)

Sometimes the duplicates aren’t separate rows at all. They sit inside one cell: a Tags column that reads crm, email, crm, sales, a list of cities pasted from a form, or notes with the same line typed twice. Google Sheets has no menu command for this. Data › Data cleanup › Remove duplicates compares whole rows and deletes repeated rows, so it never looks at the separate items inside a cell. A short formula does the job instead, and this guide builds it up step by step: one cell, a whole column, ignoring letter case, sorting, line breaks, and a quick way to find which cells have repeats at all.

The short answer

With the list in A2, put this in an empty cell (B2) and fill it down:

=IF(A2="", "", TEXTJOIN(", ", TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(A2, ","))), TRUE)))

The example

A Tags column in A, cleaned in B with the formula above:

RowA: Tags (original)B: CleanedWhy
2crm, email, crm, salescrm, email, salesThe second crm is dropped; order of first appearance is kept
3New York, Boston, New YorkNew York, BostonItems with spaces survive because the split is on the comma only
4Email, email, EMAIL, phoneEmail, email, EMAIL, phoneUNIQUE is case-sensitive, so nothing is removed (see “Ignore letter case”)
5a,,b, a ,a, bDoubled and trailing commas give no empty items; TRIM makes “ a ” match “a”
6(blank)(blank)The IF guard

Two traps that make the formula “do nothing”

1. UNIQUE without TRUE compares rows

SPLIT returns its pieces across one row. By default, UNIQUE removes duplicate rows, and a single row is always unique, so UNIQUE(SPLIT(A2, ",")) hands the list back untouched. Google’s UNIQUE help shows the second argument, by_column, which compares columns instead. Each item sits in its own column, so UNIQUE(…, TRUE) is the version that works. Turning the row into a column first with TOCOL gives the same result.

2. A delimiter of ", " splits on spaces too

According to the SPLIT help page, “each character in delimiter is considered individually” unless you set the third argument, split_by_each, to FALSE. So SPLIT(A2, ", ") splits on every comma and every space, and row 3 turns into New, York, Boston. Two fixes:

The fourth argument, remove_empty_text, is TRUE by default, so consecutive delimiters count as one. That’s why a,,b doesn’t produce an empty item.

A whole column with one formula

Instead of filling B2 down, put one formula at the top of an empty column. It also picks up rows you add later:

=BYROW(A2:A, LAMBDA(c, IF(c="", "", TEXTJOIN(", ", TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(c, ","))), TRUE)))))

BYROW runs the LAMBDA once for every row of A2:A, with c standing for that row’s cell. BYROW needs each row to come out as a single value (“Nested array results are not supported”), which TEXTJOIN guarantees. Keep the column below the formula empty, or the result can’t spill.

Ignore letter case

UNIQUE compares text exactly, so Email, email and EMAIL are three different items. To treat them as one and keep the first spelling as typed, compare a lowercase copy and keep each item whose lowercase form appears there for the first time:

=IF(A2="", "", ARRAYFORMULA(LET(p, TRIM(SPLIT(A2, ",")), k, LOWER(p), TEXTJOIN(", ", TRUE, FILTER(p, XMATCH(k, k)=SEQUENCE(1, COLUMNS(k)))))))

Inside the LET, p holds the trimmed items and k the same items in lowercase. XMATCH(k, k) finds where each lowercase item first appears, and the FILTER keeps an item only when that first position is its own (positions come from SEQUENCE(1, COLUMNS(k)), because the items run across a row). Row 4 becomes Email, phone.

If an all-lowercase result is fine, the short version is enough:

=IF(A2="", "", TEXTJOIN(", ", TRUE, UNIQUE(ARRAYFORMULA(LOWER(TRIM(SPLIT(A2, ",")))), TRUE)))

Sort the items while you’re at it

SORT sorts rows, so turn the items into a column with TOCOL first. Here UNIQUE works without TRUE because the items are already in separate rows:

=IF(A2="", "", TEXTJOIN(", ", TRUE, SORT(UNIQUE(TOCOL(ARRAYFORMULA(TRIM(SPLIT(A2, ","))))))))

Row 3 becomes Boston, New York.

Other separators: line breaks, semicolons, pipes, words

=IF(A2="", "", TEXTJOIN(CHAR(10), TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(A2, CHAR(10)))), TRUE)))
=IF(A2="", "", TEXTJOIN(" ", TRUE, UNIQUE(SPLIT(A2, " "), TRUE)))

Find which cells contain duplicates

Before you change anything, count the extra items in each cell. A result of 0 means the cell has no repeats:

=IF(A2="", "", LET(p, ARRAYFORMULA(TRIM(SPLIT(A2, ","))), COLUMNS(p)-COLUMNS(UNIQUE(p, TRUE))))

Fill it down next to the data, then sort or filter on it, or shade the rows with a conditional formatting custom formula such as =$C2>0 (if the count is in column C). The highlighting duplicates guide explains custom formulas. Replace UNIQUE(p, TRUE) with the LOWER/XMATCH logic if case shouldn’t matter.

One list of every distinct item in the column

To get a clean list of every tag used anywhere in the column, for a drop-down or a report:

=LET(t, TOCOL(ARRAYFORMULA(TRIM(SPLIT(A2:A, ","))), 3), SORT(UNIQUE(FILTER(t, t<>""))))

With ARRAYFORMULA, SPLIT runs on every row. TOCOL(…, 3) stacks all the pieces into one column and ignores blanks and errors, which covers empty rows. The FILTER drops pieces that were only spaces, and SORT and UNIQUE finish the list. For counting how often each item appears, see counting duplicates.

Replace the original cells

  1. Duplicate the tab (right-click the tab › Duplicate) so you have a way back.
  2. Select the cleaned results, copy them, click the first original cell and use Edit › Paste special › Values only.
  3. Delete the helper column. Formulas that pointed at the original column now see the cleaned text.

Pasting over the original column while the formula is still there is safe: the formula then reads the cleaned text and returns the same result. Delete the helper column straight after, so the sheet doesn’t hold two copies of the list.

When the duplicates are whole rows

If the same tag list or the same contact appears on two rows, that’s a duplicate row, and the usual tools apply: find and remove duplicates, UNIQUE vs Remove duplicates, or merge duplicate rows when the copies hold different information. Clean inside the cells first, though. crm, email, crm and crm, email only look like the same row after the in-cell repeats are gone.

Pitfalls

FAQ

Can Remove duplicates delete repeated words inside one cell?

No. Data › Data cleanup › Remove duplicates compares whole rows (or the columns you tick) and deletes repeated rows. It never looks at the separate items inside one cell. Use a formula: =IF(A2="", "", TEXTJOIN(", ", TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(A2, ","))), TRUE))).

Why does UNIQUE(SPLIT(A2, ",")) not remove anything?

SPLIT puts the items side by side in one row, and UNIQUE compares rows by default. One row is always unique, so it comes back unchanged. Set the second argument, by_column, to TRUE: UNIQUE(…, TRUE) compares the columns, which here are the items.

Why did “New York” get split into “New” and “York”?

SPLIT treats each character of the delimiter as its own separator by default, so a delimiter of ", " splits on every comma and on every space. Split on "," alone and wrap the result in TRIM, or set split_by_each to FALSE if every separator is exactly a comma followed by one space.

How do I remove duplicates in a cell without caring about upper and lower case?

UNIQUE treats Email and email as different. To keep the first spelling of each item, compare a LOWER key with XMATCH: =IF(A2="", "", ARRAYFORMULA(LET(p, TRIM(SPLIT(A2, ",")), k, LOWER(p), TEXTJOIN(", ", TRUE, FILTER(p, XMATCH(k, k)=SEQUENCE(1, COLUMNS(k))))))). If an all-lowercase result is fine, wrap the TRIM in LOWER instead.

How do I do it for a whole column at once?

Put one formula at the top of an empty column: =BYROW(A2:A, LAMBDA(c, IF(c="", "", TEXTJOIN(", ", TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(c, ","))), TRUE))))). BYROW runs the formula once per row and needs one value per row, which TEXTJOIN provides.

How do I replace the original cells with the cleaned text?

Select the formula results, copy them, select the first original cell and use Edit › Paste special › Values only. Then delete the helper column. Duplicate the tab first if you want an easy way back.

How do I get one list of every distinct tag in a column?

=LET(t, TOCOL(ARRAYFORMULA(TRIM(SPLIT(A2:A, ","))), 3), SORT(UNIQUE(FILTER(t, t<>"")))). TOCOL with 3 drops blanks and errors, and the FILTER removes pieces that were only spaces.

Duplicate rows, not just repeated words? SheetDupes (disclosure: we make it) is a Google Sheets add-on for duplicate rows. It doesn’t edit the items inside a cell, so use the formulas above for that. Once the cells are clean, pick the columns that define a duplicate row in the sidebar, preview the matching groups, highlight the extra rows without changing any values, and only then remove them or merge each group into one row. It copies a backup tab before it removes or merges anything, ignores extra spaces and, optionally, letter case and punctuation. Preview and Highlight are free on any size sheet; there is a 14-day free trial with no credit card, and writes remain free after the trial on sheets with up to 2,000 data rows during launch (through Jan 31, 2027; 500 after that). It only reads and writes the spreadsheet you have open, and your data is not sent to Loomwise. It is live on the Google Workspace Marketplace.
Install free from Google Workspace MarketplaceSee SheetDupes
Want to test it first? Try it on sample data (makes a copy of a 12-row example sheet in your Drive).

Related guides