Spreadsheet formulas explained, side by side

TRIM Function in Excel, Google Sheets, Airtable & Notion

TRIM removes spaces from the start and end of text and shrinks any run of spaces inside it to a single space. “ Quarterly report ” becomes “Quarterly report”.

Syntax in each app

AppSupportSyntax & notes
Excel✔ Built inTRIM(text)
Google Sheets✔ Built inTRIM(text)
Airtable✔ Built inTRIM(string)
Airtable's TRIM only removes spaces at the start and end. To also shrink double spaces inside the text, as Excel does, use TRIM(REGEX_REPLACE(text, " +", " ")).
Notion≈ WorkaroundreplaceAll(replaceAll(text, " +", " "), "^ | $", "")
No reliable trim function. Use replaceAll() with a regular expression: first shrink runs of spaces, then remove the one left at either end.
Try TRIM with your own values
Result (as Excel & Google Sheets return it)
Quarterly report 16 characters
Your formula, ready to paste
Excel=TRIM(" Quarterly report ") open excel.new ↗
Google Sheets=TRIM(" Quarterly report ") open sheets.new ↗
AirtableTRIM(REGEX_REPLACE(" Quarterly report ", " +", " "))
Notion
workaround
replaceAll(replaceAll(" Quarterly report ", " +", " "), "^ | $", "")

Arguments

ArgumentWhat it means
textThe text to clean.

Examples

FormulaResultWhyCopy
=TRIM(" Quarterly report ")Quarterly reportLeading, trailing and double spaces removed.
=TRIM(SUBSTITUTE(A2, CHAR(160), " "))Cleaned web textTurn non-breaking spaces into normal spaces first.
=TRIM(CLEAN(A2))No spaces or line breaksCLEAN removes line breaks and other control characters.
=LEN(A2)<>LEN(TRIM(A2))TRUE if messyFlag cells with stray spaces.

Examples use Excel / Google Sheets syntax unless noted.

How TRIM works

Stray spaces are a common reason lookups fail: “Apple ” with a trailing space does not match “Apple”, so VLOOKUP and MATCH return #N/A and COUNTIF misses rows. Clean imported or pasted data with TRIM in a helper column, then paste the results back as values.

TRIM only removes the normal space character (code 32). Text copied from web pages often contains non-breaking spaces (code 160), which TRIM leaves alone. Convert them first with =TRIM(SUBSTITUTE(A2, CHAR(160), " ")). Line breaks and tabs need CLEAN() or a SUBSTITUTE of CHAR(10).

The apps disagree on what “trim” means. Excel and Google Sheets also collapse double spaces inside the text. Airtable's TRIM only strips the ends, so the copy button adds a REGEX_REPLACE to match Excel. Notion has no trim function to rely on; two replaceAll() calls with regular expressions do the same job.

Frequently Asked Questions

Why doesn't TRIM remove all the spaces?
The remaining characters are probably non-breaking spaces (CHAR(160)) from web text. Use =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).
How do I remove every space, not just extra ones?
Use SUBSTITUTE: =SUBSTITUTE(A2, " ", "").

Part of the Text functions. Results in the tester follow Excel and Google Sheets behaviour; always double-check important work in your own file.