Remove Duplicates from Comma-Delimited Strings in Google Sheets

Published on

If you’re working with lists inside cells—like names or items separated by commas—and want to clean them up by removing duplicates, Google Sheets offers a couple of neat formula-based solutions.

This guide shows you how to remove duplicates from comma-delimited strings in individual cells or across multiple rows. Whether your delimiter is a comma, pipe (|), hyphen (-), or even a newline, these formulas will help you clean your data while keeping it neatly formatted as a string.

When Would You Need This?

Imagine a cell with the value:

Apple, Orange, Banana, Apple

You want it to become:

Apple, Orange, Banana

The problem is, UNIQUE doesn’t work directly on text strings like this—it only works on actual cell ranges. That’s where a combination of SPLIT, TRIM, UNIQUE, and TEXTJOIN comes in handy.

Let’s walk through the two main solutions.

Remove Duplicates from Comma-Delimited Strings: Non-Array Formula

If you’re only working with one cell (say, A2), here’s a straightforward formula to remove duplicate values:

Formula (for single cell A2):

=ArrayFormula(IFERROR(TEXTJOIN(", ", TRUE, UNIQUE(TRIM(SPLIT(A2, ",")), TRUE))))

How it works:

  • SPLIT(A2, ",") – Splits the string into separate values.
  • TRIM(...) – Removes leading/trailing spaces.
  • UNIQUE(..., TRUE) – Removes duplicates from the split values.
  • TEXTJOIN(", ", TRUE, ...) – Rejoins the unique values into a clean, comma-separated string.
  • IFERROR(...) – Handles empty cells or invalid inputs gracefully by preventing errors.
  • ArrayFormula(...) – Enables TRIM and other functions to process arrays of values.

To use this across multiple rows, you can drag the formula down.

Want to Use a Different Delimiter?

No problem! Replace the delimiter in both SPLIT and TEXTJOIN.

For example, to remove duplicates from a pipe-delimited string (|):

=ArrayFormula(IFERROR(TEXTJOIN("| ", TRUE, UNIQUE(TRIM(SPLIT(A2, "|")), TRUE))))

Array Formula to Remove Duplicates from Comma-Separated Strings

If your data spans multiple rows in A2:A, and you don’t want to drag the formula down manually, use this dynamic version with a Lambda Helper Function (MAP + LAMBDA):

Formula:

=ArrayFormula(MAP(A2:A, LAMBDA(r, IFERROR(TEXTJOIN(", ", TRUE, UNIQUE(TRIM(SPLIT(r, ",")), TRUE))))))

Why this is better:

  • No need to drag the formula down.
  • Automatically spills clean, duplicate-free results into column B.

This formula applies the same logic from the non-array version to each row of the range and returns the cleaned result in a single step.

Which One Should You Use?

ScenarioRecommended Formula
One-off cleanup in a single cellNon-array formula
Multiple rows of listsMAP + LAMBDA array formula
Custom delimitersModify the delimiter in SPLIT & TEXTJOIN
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.