TRIM function

Removes leading, trailing, and repeated spaces in text.

Sample Usage

TRIM(" lorem ipsum")

TRIM(A2)

Syntax

TRIM(text)

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

Notes

  • 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.

Examples

true
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.

Search
Clear search
Close search
Main menu
6070709413714714983
true
Search Help Center
true
true
true
true
true
35
false
false