TRIM function

Removes leading, trailing, and repeated spaces in text.

Sample Usage

TRIM(" lorem ipsum")




  • text - The string or reference to a cell containing a string to be trimmed.


  • Google Sheets trims text input into cells by default.

  • It is important to use TRIM when text is used in formulas or data validation because spaces in front of or after the text are significant.

  • TRIM removes all spaces in a text string, leaving just a single space between words.

  • Whitespace or non-breaking space will not be trimmed.

See Also

SUBSTITUTE: Replaces existing text with new text in a string.

REPLACE: Replaces part of a text string with a different text string.


Visit the Learning Center

Using Google products, like Google Docs, at work or school? Try powerful tips, tutorials, and templates. Learn to work on Office files without installing Office, create dynamic project plans and team calendars, auto-organize your inbox, and more.

Clear search
Close search
Google apps
Main menu