← All functions

TRIM

Quirk found

Category: Text · Last tested 2026-09-04

Real compatibility results for the TRIM function: executed in Excel for the web, Google Sheets and LibreOffice Calc, with desktop Excel behavior from Microsoft’s official documentation (we do not run desktop Excel — Excel for the web is a different application and is executed separately). Syntax and links to that documentation are below.

Support matrix

EngineDocumentedLive-testedVerdict
Excel (desktop)Yes No — documented only n/a
Excel for the web— Yes (recalc, 2026-09-01) Supported, behaves as documented
Google SheetsYes Yes (Drive import, 2026-08-29) Quirk found
LibreOffice CalcYes Yes (25.8.7.3, 2026-09-04) Quirk found

LibreOffice version history

We executed the same test cases under each LibreOffice release to show exactly when TRIM’s support changed — not documentation claims, real results.

LibreOffice versionVerdictTested
24.2.0.3 Quirk found 2026-09-04
24.8.7.2 Quirk found 2026-09-04
25.2.0.3 Quirk found 2026-09-04
25.8.7.3 Quirk found 2026-09-04

Why isn't TRIM working in LibreOffice?

TRIM exists in LibreOffice 25.8.7.3, but it is not a drop-in match for Excel — our executed tests found real behavioral differences (detailed in the test results on this page). If a formula that works in Excel or Google Sheets misbehaves in LibreOffice, compare your usage against the failing cases above before assuming your data is wrong.

Why isn’t TRIM working in Google Sheets?

TRIM runs in Google Sheets, but our executed cases show it does not match Excel’s documented behavior on every input (the failing cases are listed on this page). If a formula that behaves one way in Excel gives you a different answer in Sheets, compare your usage against those cases before assuming your data is wrong.

Discovered quirks

Executed test cases

Excel for the web (executed 2026-09-01 via OneDrive recalculation)

These values come from Excel for the web, not from desktop Excel. They are two different implementations of the calculation engine, and this run measured only the web one: the corpus was uploaded to OneDrive as .xlsx, recalculated by Excel for the web on open, and downloaded again for readback. Excel for the web is a rolling service with no pinnable version, so the run is identified by its date. Where a value here disagrees with the Expected column — which is Microsoft’s documentation of the desktop product — we cannot tell you whether the web engine diverges from the desktop one or the documentation is wrong about both, because we do not run desktop Excel.

FormulaDescriptionResultExpectedVerdict
=TRIM(" Hello World ") Leading/trailing spaces are stripped and multiple interior spaces collapse to a single space Hello World Hello World Matched
=TRIM(CHAR(9)&"Hello") TRIM only removes the regular ASCII space character (decimal 32); it does NOT remove other whitespace such as a tab (CHAR(9)), so the leading tab survives untouched Hello Hello
Provenance

Microsoft docs: "the TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text" -- it does not generalize to other whitespace. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=TRIM(CHAR(160)&"Hello"&CHAR(160)) TRIM does not remove the non-breaking space character (CHAR(160), HTML  ) even though it renders as whitespace -- a real, documented, and easy-to-miss cross-engine divergence point since data pasted from web pages is full of CHAR(160)  Hello   Hello 
Provenance

Microsoft docs state explicitly: "by itself, the TRIM function does not remove the nonbreaking space character (which has a decimal value of 160 and is commonly used in web pages as the HTML entity )." Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=TRIM("No Extra Spaces") A string with only single spaces between words passes through unchanged No Extra Spaces No Extra Spaces Matched

Google Sheets (executed 2026-08-29 via Drive import)

Google Sheets is a rolling service with no pinnable version, so this run is identified by its date. The corpus was imported to Drive as .xlsx, recalculated by Sheets, and exported back for readback.

FormulaDescriptionResultExpectedVerdict
=TRIM(" Hello World ") Leading/trailing spaces are stripped and multiple interior spaces collapse to a single space Hello World Hello World Matched
=TRIM(CHAR(9)&"Hello") TRIM only removes the regular ASCII space character (decimal 32); it does NOT remove other whitespace such as a tab (CHAR(9)), so the leading tab survives untouched Hello U+0009Hello
Provenance

Microsoft docs: "the TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text" -- it does not generalize to other whitespace. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Mismatch
=TRIM(CHAR(160)&"Hello"&CHAR(160)) TRIM does not remove the non-breaking space character (CHAR(160), HTML  ) even though it renders as whitespace -- a real, documented, and easy-to-miss cross-engine divergence point since data pasted from web pages is full of CHAR(160)  Hello   Hello 
Provenance

Microsoft docs state explicitly: "by itself, the TRIM function does not remove the nonbreaking space character (which has a decimal value of 160 and is commonly used in web pages as the HTML entity )." Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=TRIM("No Extra Spaces") A string with only single spaces between words passes through unchanged No Extra Spaces No Extra Spaces Matched

LibreOffice Calc 25.8.7.3 (tested 2026-09-04)

FormulaDescriptionResultExpectedVerdict
=TRIM(" Hello World ") Leading/trailing spaces are stripped and multiple interior spaces collapse to a single space Hello World Hello World Matched
=TRIM(CHAR(9)&"Hello") TRIM only removes the regular ASCII space character (decimal 32); it does NOT remove other whitespace such as a tab (CHAR(9)), so the leading tab survives untouched Hello Hello
Provenance

Microsoft docs: "the TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text" -- it does not generalize to other whitespace. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=TRIM(CHAR(160)&"Hello"&CHAR(160)) TRIM does not remove the non-breaking space character (CHAR(160), HTML  ) even though it renders as whitespace -- a real, documented, and easy-to-miss cross-engine divergence point since data pasted from web pages is full of CHAR(160) �Hello�  Hello 
Provenance

Microsoft docs state explicitly: "by itself, the TRIM function does not remove the nonbreaking space character (which has a decimal value of 160 and is commonly used in web pages as the HTML entity )." Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Mismatch
=TRIM("No Extra Spaces") A string with only single spaces between words passes through unchanged No Extra Spaces No Extra Spaces Matched
=LEN(TRIM(CHAR(9)&"Hello")) Length probe for the leading-tab case: if TRIM leaves the tab in place the result is 6 (tab + 5 letters); an engine that also strips tabs returns 5 6 6
Provenance

Microsoft docs: "the TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text", so a tab (CHAR(9)) survives and LEN stays 6. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=CODE(TRIM(CHAR(9)&"Hello")) Identity probe for the same case: CODE of the first surviving character is 9 (the tab) if TRIM left it alone, and 72 (the letter H) if the engine stripped it 9 9
Provenance

Numeric companion to TRIM_tab_not_removed -- CODE() makes the difference comparable across engines without depending on how a reader renders a tab. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=LEN(TRIM(CHAR(10)&"Hello")) Same probe for a leading line feed (CHAR(10)): 6 if the line feed survives TRIM, 5 if the engine strips it 6 6
Provenance

CHAR(10) is not the ASCII space (32), so documented Excel TRIM leaves it untouched. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=LEN(TRIM(UNICHAR(9)&"Hello")) The tab probe written with UNICHAR instead of CHAR, so the code point is unambiguous and does not depend on the engine's current code table 6 6
Provenance

UNICHAR(9) is U+0009 on every engine; CHAR(9) depends on the active code table (LibreOffice help: CHAR "converts a number into a character according to the current code table"). Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=LEN(TRIM(UNICHAR(160)&"Hello"&UNICHAR(160))) A genuine non-breaking space (U+00A0) on each side of the text: 7 if TRIM keeps both, 5 if an engine treats them as trimmable whitespace 7 7
Provenance

Microsoft docs: "by itself, the TRIM function does not remove the nonbreaking space character (which has a decimal value of 160 ...)", so both non-breaking spaces survive and LEN stays 7. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=UNICODE(TRIM(UNICHAR(160)&"Hello"&UNICHAR(160))) Identity probe for the same string: the first surviving character must still be the non-breaking space, code point 160 160 160
Provenance

Written with UNICHAR rather than CHAR so the input is a real U+00A0 regardless of the engine's code table; pairs with TRIM_nonbreaking_space_not_removed, which uses CHAR(160). Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=LEN(TRIM(UNICHAR(8203)&"Hello")) A leading zero-width space (U+200B) -- invisible, but not the ASCII space -- so TRIM should leave it and LEN should stay 6 6 6
Provenance

TRIM targets only the 7-bit ASCII space (32); U+200B is neither that nor a control character (so CLEAN does not remove it either). Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched
=LEN(TRIM(" a b ")) Control case: ordinary spaces only. Leading and trailing runs are stripped and the interior run collapses to one space, leaving "a b" -- length 3 3 3
Provenance

Baseline showing that the divergences in the other cases are about NON-space whitespace, not about TRIM's core space handling. Source: https://support.microsoft.com/en-us/office/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9

Matched

Docs & syntax

Related how-to recipes

Where TRIM behaves differently

Compared against other functions