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)))
- SPLIT(A2, ",") breaks the cell into separate items, side by side in one row.
- TRIM removes the spaces before and after each item, so crm and crm match. ARRAYFORMULA makes TRIM work on every item, not just the first.
- UNIQUE(…, TRUE) keeps the first appearance of each item. The
TRUEis the by_column argument, and it matters (see below). - TEXTJOIN(", ", TRUE, …) joins the remaining items back into one cell with a comma and a space, skipping empty pieces.
- IF(A2="", "", …) leaves blank rows blank. Without it, SPLIT shows an error on an empty cell.
The example
A Tags column in A, cleaned in B with the formula above:
| Row | A: Tags (original) | B: Cleaned | Why |
|---|---|---|---|
| 2 | crm, email, crm, sales | crm, email, sales | The second crm is dropped; order of first appearance is kept |
| 3 | New York, Boston, New York | New York, Boston | Items with spaces survive because the split is on the comma only |
| 4 | Email, email, EMAIL, phone | Email, email, EMAIL, phone | UNIQUE is case-sensitive, so nothing is removed (see “Ignore letter case”) |
| 5 | a,,b, a , | a, b | Doubled 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:
- Split on
","alone and let TRIM remove the spaces (the formula above). This also copes with lists where some commas have a space after them and some don’t. - Or use
SPLIT(A2, ", ", FALSE), which only works if every separator is exactly a comma followed by one space.
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
- Line breaks inside the cell: split and join on
CHAR(10), the line feed character.
=IF(A2="", "", TEXTJOIN(CHAR(10), TRUE, UNIQUE(ARRAYFORMULA(TRIM(SPLIT(A2, CHAR(10)))), TRUE)))
- Semicolons or pipes: replace
","with";"or"|", and change the TEXTJOIN delimiter to match if you want to keep the original style. - Repeated words in a sentence: split on a space. Punctuation stays attached to the word, so fox and fox. are different words.
=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
- Duplicate the tab (right-click the tab › Duplicate) so you have a way back.
- Select the cleaned results, copy them, click the first original cell and use Edit › Paste special › Values only.
- 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
- Items still don’t match after TRIM. There may be a non-breaking space (common in text copied from web pages), which ordinary trimming doesn’t treat as a space. Google’s help says the Trim whitespace tool won’t remove it either. Replace it first:
SUBSTITUTE(A2, CHAR(160), " ")in place ofA2. - Everything ends up in one cell or spreads over several columns. TEXTJOIN must wrap the UNIQUE. Without it, the items spill into the cells to the right.
- #REF! at the top of the BYROW column. Something is typed in the column below the formula. Clear it so the result can spill.
- Pasting values too early. The formula result is live. Once you paste values and delete the helper column, new rows aren’t cleaned automatically. Keep the BYROW column if the list keeps growing.
- Leading zeros or decimals change. SPLIT turns items that look like numbers into numbers, so 007 comes back as 7 and 1.50 as 1.5. To keep codes as typed, give every item a marker so it stays text, then take the marker off: replace
TRIM(SPLIT(A2, ","))withTRIM(SUBSTITUTE(SPLIT("~"&SUBSTITUTE(A2, ",", ",~"), ","), "~", ""))(use any character that never appears in your data). - A different order than you expected. UNIQUE keeps the order of first appearance. Use the SORT version if you want A to Z.
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.
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
- How to Find and Remove Duplicates in Google Sheets: Highlight, Count, Delete and Keep the Original (2026)
- How to Highlight Duplicates in Google Sheets: Conditional Formatting Formulas for One Column, Whole Rows, Repeats Only and Two Sheets (2026)
- How to Compare Two Columns or Two Sheets in Google Sheets to Find Matches and Duplicates (2026)
- Duplicates That Don’t Match Exactly in Google Sheets: Case, Extra Spaces, Gmail Dots, Phone Formats and Typos (2026)
- How to Remove Duplicates in Google Sheets but Keep the Latest, First or Highest Row per Key (2026)
- How to Prevent Duplicate Entries in Google Sheets: Data Validation Rules, Warnings and a Small Script (2026)
- How to Count Duplicates in Google Sheets: per Value, Extra Rows, Unique Counts and Why the Numbers Disagree (2026)
- How to Combine Two Lists or Several Tabs in Google Sheets Without Duplicates: VSTACK, UNIQUE, One Row per Key and Other Files (2026)
- How to Merge Duplicate Rows in Google Sheets: Sum the Numbers, Join the Notes and Fill the Blanks (2026)
- UNIQUE vs Remove Duplicates in Google Sheets: Live or Static, Letter Case, Spaces, Columns and Headers (2026)
- How to Show Only the Duplicates in Google Sheets: Filter Duplicate Rows, List Repeated Values and Find Rows That Appear Once (2026)
- How to Find Duplicates Across Multiple Columns in Google Sheets: Rows That Match on Two or More Columns, and Values Repeated Anywhere in a Range (2026)
- How to Remove Duplicates Automatically in Google Sheets: Apps Script on a Daily Timer, on Form Submit or From a Menu (2026)
- How to Find Duplicates in Google Sheets but Ignore Blank Cells: Highlight, Count, List and Remove Without Empty Rows Getting in the Way (2026)
- How to Find Duplicate Transactions in Google Sheets: Double-Imported Rows, Invoices Paid Twice and Same-Amount Charges Within a Few Days (2026)
- How to Format Phone Numbers in Google Sheets: Strip Dashes and Spaces, Show (555) 010-1234, Handle +1 and Extensions, Then Find Duplicate Contacts (2026)
- How to Change Text Case in Google Sheets: UPPERCASE, lowercase, Proper Case Names, Sentence Case and Duplicates That Differ Only in Case (2026)