ShareYourGroupShareYourGroupGoogle Sheets

Guides

Cleaning data in Google Sheets

Data from forms, exports and copied web pages is rarely tidy. Names have stray spaces and odd capitals, one column holds two facts, numbers arrive as text. Google Sheets has both menu commands and functions for cleaning, and its text-splitting and pattern functions make some jobs much shorter than in other spreadsheets.

Sample sheet: Text as people really type it: stray spaces, mixed capitals, codes with dashes.
ABCD
1Full nameEmailCodeAmount as text
2  asha   verma asha.verma@example.comPB-10-12341,250
3RAVI KUMARravi@example.orgDL-08-0042300
4meena gillmeena.gill@example.comMH-12-9876 45.50 
5Kabir Khankabir@example.netRJ-14-000712 kg

For a one-time tidy of the data itself, the menus are quickest.

Use formulas, below, when the cleaning must happen again each time new data arrives.

1. Spaces and capitals

PROPER is a first pass only. It gets abbreviations and names with inner capitals wrong, so read the result.

2. Splitting

SPLIT drops empty pieces and turns number-like pieces into numbers, which loses leading zeros. When that matters, extract instead.

3. Extracting by pattern

See REGEXEXTRACT.

4. Removing and replacing

5. Text into numbers

For a whole column, select it and choose Format, Number, Number. Sheets converts text that it can read as numbers. Values with units or stray characters need a formula.

6. Joining

7. Checking

Put a check in a helper column and filter for the failures.

8. Duplicates

=COUNTIF(A:A, A2)>1 flags repeated values. =UNIQUE(A2:A) lists each value once, somewhere else, leaving the data untouched. Clean spaces and case first, or "Asha" and "asha " will count as different people.

A whole column from one formula

Each cleaning formula can run down a column inside ARRAYFORMULA, so that new rows are cleaned as they arrive:

=ARRAYFORMULA(IF(A2:A="", "", PROPER(TRIM(A2:A))))

This is the usual set-up for responses from a Google Form: leave the response tab alone, and build a clean copy on another tab with one formula per column.

Making the clean version permanent

Formulas give their results in other cells. To replace the originals, copy the cleaned cells, then use Edit, Paste special, Values only over the original column, and delete the helper column. Keep a copy of the raw data on another tab until you are sure, or rely on File, Version history.

What to leave as text

Phone numbers, PIN codes, account numbers and other identifiers should stay as text. As numbers they lose leading zeros, and you never add them up. Format such columns as Plain text before pasting data in.

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.