TRIM Function in Apple Numbers: Syntax, Examples, and Troubleshooting
Remove extra spaces from imported text in Apple Numbers without modifying source values.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
TRIM removes extra spaces from text: leading and trailing spaces are removed, and repeated internal spaces become one. The original input is unchanged when the formula’s result is placed in a separate cell.
For the input with two spaces before Acme, three between the words and two afterward, the cleaned result is Acme Labs. A cleanup result is still a label, not proof of a supplier’s identity.
Availability and version history
- Introduced: Documented in Apple’s Formulas and Functions Help 15.4; the original introduction release is not established.
- Availability: Currently documented in Apple’s Formulas and Functions Help 15.4 edition; this is not a Numbers app version or a final supported-version endpoint.
- Scope: Shared iWork function help. Availability in individual clients and older releases is not established by this check.
- Checked: October 14, 2026, against the official TRIM reference. Official documentation and independent text checks; no native Numbers execution.
Syntax and the ordinary-space examples
TRIM(source-string)
The TRIM reference has one required argument, described as any value. It specifies removal of exterior spaces and duplicate spaces between characters. It does not offer a second argument for a different cleanup mode.
The exercises use ordinary space characters deliberately. The brief source does not promise removal of every nonbreaking space, tab, line break, invisible Unicode character or control code. Similar-looking whitespace must not be assigned the same behavior without evidence.
Preserve the four original supplier labels
Create Vendors, with seven columns A:G and six rows, one header row. Put Imported name, Cleaned name, Raw length, Cleaned length, Removed, Unchanged? and Cleanup flag in A1:G1.
For reliable entry, put these formulas in A2:A5. The quotation characters delimit strings in the formulas; they are not part of the resulting text:
| Cell | Input formula | Expected cleaned B |
|---|---|---|
| A2 | =" Acme Labs " |
Acme Labs |
| A3 | =" West Coast " |
West Coast |
| A4 | =" Alix " |
Alix |
| A5 | ="Green Valley" |
Green Valley |
These formulas preserve the original four exact strings and their intentional spaces. B2 =TRIM(A2) filled through B5 gives the results above. You can instead type the strings as Text, provided every stated space is retained.
Count what changed without overwriting the source
Enter C2 =LEN(A2), D2 =LEN(B2), E2 =C2-D2, F2 =EXACT(A2,B2) and G2 =IF(E2>0,"Spacing changed","No ordinary-space reduction"). Fill C2:G2 through row 5.
| Row | Raw C | Cleaned D | Removed E | Unchanged F | G |
|---|---|---|---|---|---|
| 2 | 15 | 9 | 6 | FALSE | Spacing changed |
| 3 | 15 | 10 | 5 | FALSE | Spacing changed |
| 4 | 8 | 4 | 4 | FALSE | Spacing changed |
| 5 | 12 | 12 | 0 | TRUE | No ordinary-space reduction |
For Acme, the raw count is 2+4+3+4+2=15; the cleaned count is 4+1+4=9. The original expressions =LEN(A2), =LEN(TRIM(A2)) and their difference remain 15,9,6. West Coast similarly retains the original 15,10,5 checks.
LEN counts the text’s graphemes; EXACT compares the complete strings. A zero removal count is a statement about this transformation, not a certificate that the source is correct or free of all invisible characters.
Apple’s literal example and a second pass
Create TrimControls, with four columns and four rows. Put =" spaces spaces spaces " in A2 and =TRIM(A2) in B2. Apple’s example gives spaces spaces spaces. C2 =LEN(A2) is 22, and D2 =LEN(B2) is 20.
In B3 put =TRIM(B2) and C3 =EXACT(B2,B3) for TRUE. Once the specified ordinary-space cleanup has produced single separators and no edge spaces, applying that same cleanup again leaves this result unchanged. This check concerns the given string, not every possible imported character sequence.
Advanced: different raw labels can collapse to one name
Create LabelCollisions, with six columns and five rows, one header row. Put Record ID, Raw label, Cleaned label, Cleaned count, Removed and Unchanged? in A1:F1. Enter IDs V-101,V-102,V-103,V-104 in A2:A5. Put these formulas in B2:B5 respectively:
=" A B "
="A B"
="A B"
="AB"
C2 =TRIM(B2) filled through C5 gives A B,A B,A B,AB. D2 =COUNTIF($C$2:$C$5,C2) filled through D5 gives 3,3,3,1. All three A B labels are literally identical here, so no case-sensitivity assumption is needed to interpret that count.
E2 =LEN(B2)-LEN(C2) filled through E5 gives 3,0,1,0. F2 =EXACT(B2,C2) filled through F5 gives FALSE,TRUE,FALSE,TRUE. The four record IDs remain distinct even though three cleaned labels coincide.
COUNTIF counts matching cleaned labels; it does not decide which record should survive a deduplication process. Keep IDs and originals when resolving such collisions.
Spacing cleanup does not correct case or punctuation
On a separate CaseAndSpaces table with four columns and four rows, enter =" acme labs " in A2 and =TRIM(A2) in B2. B2 is acme labs, still lowercase. C2 =EXACT(B2,"Acme Labs") is FALSE. D2 =EXACT(UPPER(B2),UPPER("Acme Labs")) is TRUE for these ASCII letters because a separate UPPER transformation changes the case policy.
Do not remove punctuation, accents or meaningful separators merely because some spaces were unwanted. Exact whitespace classes beyond the ordinary-space contract, numeric/date conversion, truly empty cells and error inputs remain unverified in native Numbers.
Platform and text boundaries
These examples use local references within the named Numbers table. English multi-argument formulas use commas; Apple’s syntax guidance specifies semicolons when the decimal separator is a comma. A one-argument formula such as LEN or TRIM has no argument separator to change.
The help edition does not establish identical Unicode, imported-value, numeric/date conversion or error behavior in every client and historical release. Keep identifiers as text when zeros, spaces or punctuation matter. A matching length or cleaned label is not proof of a valid or unique record.