Google Sheets TRIM Function: Syntax, Examples & Tips

The TRIM function removes extra spaces from text, leaving only single spaces between words and eliminating leading or trailing spaces.
Google Sheets
TRIM(text)

One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.

On this page
  1. Parameters
  2. What is the TRIM Function?
  3. A Practical Example
  4. TRIM Formula
  5. Result of the Formula
  6. Why Use TRIM?
  7. Key Takeaways:
  8. Example use case

Parameters

text:
The text string or cell reference that you want to remove leading and trailing spaces from.

What is the TRIM Function?

The TRIM function in Google Sheets is a simple yet effective tool used to remove extra spaces from text. It eliminates leading, trailing, and multiple spaces between words, ensuring that your data is clean and properly formatted. This function is particularly useful when importing data from other sources, where extra spaces can cause issues in data analysis and processing.

In simpler terms, TRIM helps you tidy up your text by getting rid of unnecessary spaces, making your data more consistent and easier to work with.

A Practical Example

Imagine you have a list of customer names that you need to clean up:

Customer Names Table:

CustomerIDCustomerName
1John Doe
2Jane Smith
3Alice Johnson
4Bob Brown

You notice that some names have extra spaces, which can lead to inconsistencies in your records.

TRIM Formula

To clean up the customer names, you would use the TRIM function as follows:

Google Sheets
=TRIM(B2)

In this formula:

  • B2 is the cell containing the CustomerName that you want to clean.

Result of the Formula

When you apply the TRIM formula to the Customer Names Table, the output would look like this:

CustomerIDCustomerNameCleanedName
1John DoeJohn Doe
2Jane SmithJane Smith
3Alice JohnsonAlice Johnson
4Bob BrownBob Brown

The new column "CleanedName" shows the names without any extra spaces.

Why Use TRIM?

TRIM is beneficial because it ensures that your text data is clean and standardized. This is crucial for tasks such as data sorting, filtering, and matching, where extra spaces can lead to errors or unexpected results. By using TRIM, you can enhance the quality of your data and improve the overall accuracy of your analyses.

Key Takeaways:

  • TRIM: A function that removes extra spaces from text, ensuring clean and consistent data.
  • Simplicity: Easy to use and can be applied to any text string in your spreadsheet.
  • Data Quality: Helps maintain high data quality by eliminating formatting issues caused by extra spaces.
  • Common Use Cases: Ideal for cleaning up imported data, preparing text for analysis, and ensuring consistency in datasets.

TRIM is an essential function for anyone working with text data in Google Sheets, providing a straightforward way to enhance data quality and usability.

Happy spreadsheeting!

Example use case

You have a list of customer feedback in Column A, but some entries have extra spaces. By using the TRIM formula, you can clean up the data in Column B, ensuring that all feedback is formatted consistently for better analysis and reporting.

Need more help with Google Sheets formulas?

Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.

Explore all Google Sheets formulas

Browse our complete library of Google Sheets formula guides

Compare your options

Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

  1. 01ChatGPTOpen a balanced comparison prompt in ChatGPT.
  2. 02ClaudeOpen the same research prompt in Claude.
  3. 03PerplexityResearch the comparison with linked web sources.

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.