Formulas Google Sheets

How to Clean Messy Data in Google Sheets: 5 Tricks + a Bonus (Free Practice File)

You download a customer list from some software, open it in Google Sheets, and it is a mess. Names have extra spaces. Some are in capitals, some in small letters. A few email addresses are broken, and the same order appears three times. Before you can build a report from that data, you have to clean it, and doing it by hand can take hours.

In this step-by-step tutorial you will clean all of it in seconds with five simple Google Sheets tricks (TRIM and CLEAN, PROPER/LOWER/UPPER, SPLIT, UNIQUE and ISEMAIL) plus a bonus trick that cleans a whole column with one formula. Every screenshot below comes from the finished practice file, so you can check your result at each step.

Free practice file: make your own copy of the practice sheet and type along. The download at the end of this post has the view link, the copy link and the full formula cheat sheet.

Watch the video tutorial

Video overview

The 11-minute video builds every formula on screen, slowly and one step at a time. It starts with a practice sheet full of messy data: names with hidden spaces, a name split over two lines by a line break, names and emails in random capitals, “City, State” in one cell, an order list with three repeated orders, and eight email addresses of which four are broken. Tip by tip, the green cells fill in: TRIM and CLEAN remove the spaces and invisible characters, PROPER, LOWER and UPPER fix the capitals, SPLIT separates names and places, UNIQUE and the Remove duplicates menu take 12 orders down to 9, and ISEMAIL flags the four bad addresses. The bonus shows how ARRAYFORMULA runs TRIM and PROPER on a whole column from a single cell. The chapters are listed below the video on YouTube.

What you will learn

  • TRIM + CLEAN: remove extra spaces and hidden line breaks
  • PROPER, LOWER and UPPER: fix capital letters in names, emails and codes
  • SPLIT and Data > Split text to columns: break one column into many
  • UNIQUE and Data > Data cleanup > Remove duplicates: drop repeated rows
  • ISEMAIL: catch broken email addresses before you send anything
  • Bonus: ARRAYFORMULA: clean a whole column with one formula

The practice file

The file has three sheets. Practice is where you work, Solution has every formula already written, and Read Me explains each tip. On the Practice sheet the white and grey cells hold the messy data and the green cells are empty. That is where you type the formulas.

Clean messy data practice sheet in Google Sheets with messy names and empty green formula cells
The Practice sheet: messy data on the left, empty green cells for your formulas.

Tip 1: Remove extra spaces and hidden characters with TRIM and CLEAN

Look at the first table. “Rahul Sharma” has two spaces in front of the name, and “Neha Kapoor” has three spaces in the middle. Some spaces you can see and some you cannot, which is why the practice file has a Length Before column (=LEN(B7)). It counts every character, including spaces: “Rahul Sharma” is only 12 characters, but the length says 14.

Step 1: Type the TRIM formula

Click cell D7 and type:

=TRIM(B7)

Press Enter. The result is Rahul Sharma, and the Length After column drops from 14 to 12: both extra spaces are gone. Google Sheets may also offer a Suggested autofill for the rest of the column.

TRIM formula in Google Sheets removing extra spaces, with the Suggested autofill prompt
=TRIM(B7) returns Rahul Sharma; the length falls from 14 to 12.

Step 2: Copy it down

Click D7, press Ctrl + C, select D8:D14 and press Ctrl + V. Look at Neha Kapoor: the three spaces in the middle have become one. TRIM removes spaces at the start, spaces at the end, and squeezes repeated spaces between words down to one.

TRIM formula copied down to all eight names in Google Sheets with the new lengths
All eight names trimmed. Compare Length Before and Length After.

Step 3: Add CLEAN for line breaks and tabs

The second table holds text pasted from another system. “Rohan Patel” shows on two lines because a line break sits in the middle of the name, and TRIM cannot remove it: TRIM only handles spaces. Wrap CLEAN inside TRIM. In D18 type:

=TRIM(CLEAN(B18))

Rohan Patel is back on one line and the length goes from 12 to 11. Copy it to D19:D20: “Vikas Malhotra” had a hidden tab character, and that is gone too. Rule of thumb: TRIM for spaces, CLEAN for invisible characters, and use them together.

TRIM and CLEAN formula in Google Sheets removing a hidden line break from a name
=TRIM(CLEAN(B18)) removes the hidden line break that TRIM alone cannot see.

Tip 2: Fix capital letters with PROPER, LOWER and UPPER

In this table the names are typed every possible way (rAHUL sHARMA, NEHA KAPOOR, arjun mehta), the emails are in mixed case and the invoice codes are mixed too.

Messy names, emails and invoice codes in mixed capital letters in Google Sheets
Names, emails and codes in random capitals.

Google Sheets has one function for each job. Type these three formulas in row 26:

E26:  =PROPER(B26)   → Rahul Sharma (first letter of every word capital)
F26:  =LOWER(C26)    → rahul.sharma@example.com (all small letters)
G26:  =UPPER(D26)    → INV-2026-101 (all capitals)
PROPER formula in Google Sheets fixing the capital letters of a name
=PROPER(B26) turns rAHUL sHARMA into Rahul Sharma.

Then select E26:G26, copy, select E27:G31 and paste. All six rows are cleaned in one go.

PROPER, LOWER and UPPER formulas in Google Sheets cleaning names, emails and invoice codes
PROPER for names, LOWER for emails, UPPER for codes.

Tip 3: Split one column into many

The SPLIT function

The full name sits in one cell, but you want first and last name in separate columns. In D37 type:

=SPLIT(B37," ")

The space in the quotes is the separator. “Rahul” lands in column D and “Sharma” spills into column E by itself, although you typed the formula in one cell only.

SPLIT formula in Google Sheets splitting a full name into first and last name
=SPLIT(B37,” “) splits the name on the space.

For “City, State” use a comma and a space as the separator, and add FALSE:

=SPLIT(C37,", ",FALSE)

That third argument (split_by_each) set to FALSE tells Google Sheets to treat “, ” as one separator. Without it, every comma and every space would split the text, and “Tamil Nadu” would break into two pieces.

SPLIT results in Google Sheets with first name, last name, city and state in separate columns
Both SPLIT formulas copied down. Tamil Nadu stays in one cell.

The menu way: Split text to columns

Below, the product codes join the category, size and colour with a dash (TSHIRT-M-BLUE). First copy the codes into the Category column (Ctrl + Shift + V pastes values only), so the originals stay safe. Then go to Data > Split text to columns, open the separator list and choose Custom, then type a dash.

Split text to columns separator menu in Google Sheets with the Custom option
Data > Split text to columns: choose Custom and type “-“.
Product codes split into category, size and colour with Split text to columns in Google Sheets
The codes split into Category, Size and Colour.

Tip 4: Remove duplicates with UNIQUE and Data cleanup

This order list has 12 rows, but ORD-1002, ORD-1003 and ORD-1005 each appear twice. Total this list and your sales figure will be wrong.

Order list in Google Sheets with duplicate order IDs
12 rows, three of them repeats.

The formula way: UNIQUE

In F56 type the formula below and select the whole list, B56 to D67:

=UNIQUE(B56:D67)

You get 9 unique orders, and the original list is not touched at all. The counters under the tables show 12 rows in the list and 9 unique rows.

UNIQUE formula in Google Sheets returning the unique rows of an order list
=UNIQUE(B56:D67) spills the 9 unique orders.

The menu way: Remove duplicates

To delete the repeats from the list itself, select B56:D67 and go to Data > Data cleanup > Remove duplicates. The same submenu also has Trim whitespace, which trims a whole range without a formula.

Data cleanup menu in Google Sheets showing Remove duplicates and Trim whitespace
Data > Data cleanup > Remove duplicates.

Click the Remove duplicates button. Google Sheets reports “3 duplicate rows found and removed. 9 unique rows remain.” Click OK, and the count under the list changes from 12 to 9.

Remove duplicates result in Google Sheets: 3 duplicate rows found and removed, 9 unique rows remain
3 duplicate rows removed, 9 unique rows remain.

Tip 5: Catch broken email addresses with ISEMAIL

Before you send any email campaign, check the list. Four of these eight addresses are wrong: one has no “.com”, one has a space in the middle, one has two @ signs and one has no @ at all. In C74 type the formula below and copy it down to C81:

=ISEMAIL(B74)

Every broken address shows FALSE.

ISEMAIL formula in Google Sheets returning TRUE and FALSE for valid and broken email addresses
ISEMAIL returns FALSE for every broken address.

TRUE and FALSE are fine for you, but a team reads words more easily. Wrap ISEMAIL in IF, in D74:

=IF(ISEMAIL(B74),"Valid","Fix it")

Copy it down: four addresses to fix. Remember that ISEMAIL checks the format of an address (one @, a domain, no spaces). It does not check whether the inbox really exists.

IF and ISEMAIL formula in Google Sheets showing Valid or Fix it for each email address
=IF(ISEMAIL(B74),”Valid”,”Fix it”): a status the whole team understands.

Bonus: Clean a whole column with ONE formula (ARRAYFORMULA)

So far you wrote one formula and copied it down. The last table has names with both problems, extra spaces and wrong capitals, and you can clean all of them from a single cell. Click C87, type =ARRAYFORMULA(PROPER(TRIM(, then select the whole range B87:B94 and close all three brackets:

=ARRAYFORMULA(PROPER(TRIM(B87:B94)))
Building an ARRAYFORMULA with PROPER and TRIM over a range in Google Sheets
Select the whole range B87:B94 inside TRIM.

All eight names are cleaned in one shot. TRIM removes the extra spaces, PROPER fixes the capital letters, and ARRAYFORMULA runs both on the whole range, from the one formula in C87.

ARRAYFORMULA with PROPER and TRIM cleaning eight names from one formula in Google Sheets
One formula in C87 cleans all eight names.

Formula cheat sheet

Problem Formula / menu Example result
Extra spaces =TRIM(B7) Length 14 → 12
Hidden line breaks, tabs =TRIM(CLEAN(B18)) Two lines → one line
Names in random case =PROPER(B26) rAHUL sHARMA → Rahul Sharma
Emails in mixed case =LOWER(C26) all small letters
Codes in mixed case =UPPER(D26) INV-2026-101
Full name in one cell =SPLIT(B37," ") Rahul | Sharma
“City, State” in one cell =SPLIT(C37,", ",FALSE) Chennai | Tamil Nadu
Codes joined with a dash Data > Split text to columns > Custom “-“ TSHIRT | M | BLUE
Repeated rows (keep the list) =UNIQUE(B56:D67) 12 rows → 9 unique
Repeated rows (delete them) Data > Data cleanup > Remove duplicates 3 removed
Broken email addresses =IF(ISEMAIL(B74),"Valid","Fix it") 4 to fix
A whole column at once =ARRAYFORMULA(PROPER(TRIM(B87:B94))) 8 names, 1 formula

Formula or menu: which should you use?

Formula (TRIM, SPLIT, UNIQUE…) Menu (Split text to columns, Remove duplicates, Trim whitespace)
Original data Kept, results go in new cells Changed in place
New or changed data Updates by itself Run it again
Best for Lists you refresh every week A one-time cleanup of an import

Use formulas when the data keeps coming, and menus when you just need to fix a file once.

Quick tips

  • Keep the cells next to SPLIT and UNIQUE empty. They spill into neighbouring cells; if something is in the way you get an error.
  • Use LEN to prove the cleanup worked. A length that drops after TRIM is the easiest check.
  • Paste values when you need a static clean list. Copy the formula results and use Ctrl + Shift + V.
  • Clean before you analyse. Pivot tables, lookups and charts all break on hidden spaces and duplicates. See the XLOOKUP in Google Sheets tutorial for what to do with the clean data next.

More time-savers: 7 Google Sheets hacks that save hours. Keeping an email list? The Newsletter & Email List Growth Tracker pairs well with the ISEMAIL check. The full list of functions is in Google’s Google Sheets function list.

Frequently asked questions

What is the difference between TRIM and CLEAN in Google Sheets?

TRIM removes extra spaces: at the start, at the end and repeated spaces between words. CLEAN removes non-printing characters such as line breaks and tabs, which TRIM does not touch. For text pasted from other systems use both: =TRIM(CLEAN(A2)).

Does Google Sheets have a built-in way to remove extra spaces without a formula?

Yes. Select the range and use Data > Data cleanup > Trim whitespace. It changes the cells in place, while TRIM leaves the original and returns a clean copy.

How do I capitalize the first letter of each word in Google Sheets?

Use PROPER, for example =PROPER(B26) turns “rAHUL sHARMA” into “Rahul Sharma”. Use LOWER for all small letters and UPPER for all capitals.

Why does SPLIT break “Tamil Nadu” into two cells?

By default SPLIT treats every character in the delimiter as its own separator, so “, ” splits on the comma and on the space. Add FALSE as the third argument, =SPLIT(C37,", ",FALSE), to treat “, ” as one separator.

What is the difference between UNIQUE and Remove duplicates?

UNIQUE is a formula: it returns the unique rows in new cells and leaves the original list untouched, and it updates when the list changes. Remove duplicates (Data > Data cleanup) deletes the repeated rows from the selected range itself, once.

Does ISEMAIL check if an email address really exists?

No. ISEMAIL only checks that the text is shaped like an email address: one @, a domain and no spaces. A correctly written address with a mailbox that does not exist still returns TRUE.

Can I clean a whole column with one formula?

Yes, with ARRAYFORMULA. For example =ARRAYFORMULA(PROPER(TRIM(B87:B94))) trims and fixes the capitals of eight names from a single cell.

Conclusion

Messy data does not need hours of manual fixing. TRIM and CLEAN handle spaces and hidden characters, PROPER, LOWER and UPPER fix the capitals, SPLIT separates what belongs in different columns, UNIQUE and Remove duplicates get rid of repeated rows, and ISEMAIL catches broken addresses. ARRAYFORMULA then lets you apply the cleanup to a whole column at once. Open the practice file, type each formula yourself, and compare with the Solution sheet. Typing is how these stick.

Recap of the five Google Sheets tricks to clean messy data plus the ARRAYFORMULA bonus
Quick recap: 5 tricks plus the bonus.

Written by PK, NeoTech Navigators: step-by-step Google Sheets and Excel tutorials with free practice files.

Download the free practice file

Everything in one page: the view-only Google Sheets link, a one-click Make a copy link, and the full formula cheat sheet from this tutorial.

Free · No sign-up · Opens the Google Sheet in view-only mode, then copy it to your own Drive

PK
Meet PK, the founder of NeotechNavigators.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your data analysis skills to the next level!
https://neotechnavigators.com