✂️ Clean Up Unwanted Spaces with the TRIM Function (Google Sheets)
When working with text in Google Sheets, unnecessary spaces can disrupt sorting, filtering, or comparing data.
The TRIM
function is a simple yet powerful tool that removes extra spaces from text, keeping your data clean and consistent.
✅ Syntax of the TRIM Function
=TRIM(text)
- text: The string or cell reference from which you want to remove extra spaces.
The TRIM function removes leading and trailing spaces, and also reduces multiple spaces between words to a single space.
✍️ Examples
Example 1: Remove leading and trailing spaces
=TRIM(" Hello World ")
📌 Result: "Hello World"
Example 2: Normalize multiple spaces
=TRIM("Google Sheets function")
📌 Result: "Google Sheets function"
Example 3: Trim data from a cell
Assume cell A1
contains: " data science "
=TRIM(A1)
📌 Result: "data science"
Example 4: Combine with other functions
Convert trimmed name to uppercase:
=UPPER(TRIM(" james kim "))
📌 Result: "JAMES KIM"
💡 Practical Use Cases
- Data Cleanup: Useful for removing hidden spaces when importing data from external sources.
- Avoid Lookup Errors: Prevents mismatches caused by invisible spaces in
VLOOKUP
,MATCH
, etc. - Clean email/phone fields: Ensures input fields are free from accidental spaces.
- Combine with CONCAT or
&
: Ensures clean text when joining strings.
🧩 Notes
- TRIM only removes extra spaces; single spaces between words are kept.
- To remove line breaks or non-printable characters, use it together with the
CLEAN
function.
🧠 Summary Table
Item | Description |
---|---|
Function | TRIM |
Purpose | Removes unwanted spaces |
Input | Text or cell reference |
Output | Cleaned-up text |
Best Use | Data cleaning, lookup fixes, automation accuracy |
The TRIM function is an essential part of any spreadsheet toolkit.
By using it regularly, you ensure that your data stays clean, searchable, and easy to manage — even when imported from messy sources.