What the video covers
Apply native Google Sheets functions and the built-in Trim whitespace tool to sanitize text in cells. This guide covers removing leading/trailing spaces, repeated inline spaces, non-printable characters (including CHAR(10) line breaks), and non-breaking spaces.
Watch the video on YouTubeStep-by-step instructions
- Open your spreadsheet and choose a helper column
Work in a new column next to your raw text so you can preview cleaned values before replacing original cells. - Remove leading/trailing and repeated spaces with TRIM
Enter =TRIM(A2) (adjust A2 to your cell) to remove leading, trailing and duplicate internal spaces, then fill down the column. - Strip non-printable characters and line breaks with CLEAN
Enter =CLEAN(A2) to remove many non-printable characters including CHAR(10) line returns. Use this when text has visible line breaks or returns. - Combine TRIM and CLEAN for most cases
Use =TRIM(CLEAN(A2)) to remove both extra spaces and common non-printable characters in one step. - Remove non-breaking spaces and other stubborn whitespace with REGEXREPLACE
For web-imported or special-space characters, use a regex to normalize spaces, for example: =TRIM(CLEAN(REGEXREPLACE(A2, "\s+", " "))) which replaces runs of whitespace (including non-breaking spaces in many cases) with a single regular space before trimming and cleaning. - Use the built-in Trim whitespace tool for bulk trimming
To remove leading/trailing spaces from a range without formulas, highlight the range, open the Data cleanup/Trim whitespace tool and run it. This handles simple leading/trailing whitespace quickly. - Replace raw data with cleaned values
Once results look correct, copy the helper column, right-click over the original range and choose Paste special → Values only to overwrite with cleaned text.
Watch the video
Play tutorial
Why it matters
Invisible line returns and extra spaces can break matches, joins, and filters. Cleaning text ensures consistent values for lookups, merges, and reporting.
Check your result
After cleaning, test with a known lookup or exact-match comparison (for example, compare cleaned cell to expected value using =A2=B2 or run your VLOOKUP). There should be no unexpected mismatches caused by hidden characters.
Troubleshooting
If cleaned results still fail to match: 1) Look for non-printable characters not removed by CLEAN (use CODE or UNICODE on a single character) and remove via REGEXREPLACE. 2) Non-breaking spaces (CHAR(160)) require targeted replacement—see step below. 3) If formulas look correct but values remain, ensure you pasted values-only over the original cells. 4) For imported web content, run CLEAN and REGEXREPLACE together because different sources introduce different invisible characters.