Contact

CLEAN Function in Apple Numbers: Syntax, Examples, and Troubleshooting

Text Beginner Apple Numbers

Remove common invisible control characters from imported text in Apple Numbers without losing ordinary spaces.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

CLEAN removes the common nonprinting characters with Unicode codes 0–31. It does not remove every invisible character or collapse ordinary spaces. For imported text, inspect what is actually stored before choosing a cleanup rule.

Availability and version history

  • Introduced: The first Numbers introduction release and date are not established by the checked sources.
  • Availability: Documented in Apple’s Formulas and Functions Help 15.4 edition; no final supported-version endpoint is established.
  • Scope: Shared iWork function documentation. The help edition is not an application version; individual clients, older releases and import/export parity remain separately unverified.
  • Checked: October 14, 2026, against the official CLEAN reference. Examples were independently checked from the documented text rules; no native Numbers execution was performed.

Syntax and the documented exclusions

CLEAN(text)

Apple’s CLEAN entry accepts any value and has one required argument. There is no optional mode or default. It explicitly identifies codes 127,129,141,143,144,157 as nonprinting characters that CLEAN does not remove by itself, and points to SUBSTITUTE for targeted changes.

The source example describes imported text whose unwanted characters appear as question-mark glyphs. That does not mean an ordinary literal question mark is removable: its code 63 is outside the stated control range. The underlying character matters more than its appearance.

Preserve the original printable-text controls

Create a table named Imported Text Audit, with six columns and seven rows, one header row and no header columns. Put Original, Cleaned, Input length, Result length, Removed and Same text in A1:F1. Enter the formulas below in A2:A5 so that every space is reproducible:

Row Formula in A Expected B Input and output length
2 ="Report" Report 6
3 ="A B" A, two spaces, B 4
4 =" Item " two spaces, Item, two spaces 8
5 ="Text?" Text? 5

Put =CLEAN(A2) in B2, =LEN(A2) in C2, =LEN(B2) in D2, =C2-D2 in E2 and =EXACT(A2,B2) in F2. Fill B2:F2 through row 5. All E values are 0, and all F values are TRUE.

The two ordinary internal spaces in A3 remain, as do the four edge spaces in A4. TRIM has a different purpose. On a separate SpaceComparison table with three columns and four rows, enter =" Item " in A2, =CLEAN(A2) in B2 and =TRIM(A2) in C2. B2 retains eight characters; C2 is Item, with four.

A real tab is different from a typed marker

The preserved five-case input and calculation record includes a field containing A, a tab and B, and another containing A, a line feed and B. Their documented-rule expected cleaned strings are both AB. The record is an independent model, not a native test log or a ready-made import workbook.

If actual imported data contain these three code points in one cell, use a separate table named ImportedControls, with five columns and four rows. Put the tab-containing field in A2 and the line-feed-containing field in A3. B2 =CLEAN(A2) filled through B3 has the expected text AB. C2 =CODE(MID(A2,2,1)) filled through C3 has the codepoint expectations 9 and 10; D2 =EXACT(B2,"AB") filled through D3 is TRUE.

This scenario is conditional on the controls remaining inside their cells. An importer may instead split a tab into columns or a line feed into records. Do not type the literal characters backslash-t or the word TAB and treat that as the same test.

Apple’s CHAR reference permits codes from 32 to 65535, excluding 127–159 and illegal characters. Therefore CHAR(9) and CHAR(10) are outside its documented domain and cannot supply these Numbers fixtures. The CODE reference reads only the first character of its input; MID selects the second character before CODE examines it.

Advanced: replace a nonbreaking space deliberately

Create NonbreakingSpaces, with seven columns and six rows, one header row and no header columns. In A2 enter ="A"&CHAR(160)&"B". Code 160 is allowed by CHAR and represents a nonbreaking space, outside CLEAN’s stated 0–31 removal set.

Enter these separate checks:

Cell Formula Expected result
B2 =CLEAN(A2) A, nonbreaking space, B
C2 =SUBSTITUTE(B2,CHAR(160)," ") A, ordinary space, B
D2 =CODE(MID(B2,2,1)) 160
E2 =CODE(MID(C2,2,1)) 32
F2 =LEN(C2) 3
G2 =EXACT(C2,"A B") TRUE

This supplies the earlier combined pipeline =SUBSTITUTE(CLEAN(A2),CHAR(160)," ") as two visible stages. The three-argument SUBSTITUTE form replaces every occurrence of the chosen text, as documented by Apple.

In A3 enter =" A"&CHAR(160)&" "&CHAR(160)&"B ". Fill B2:G2 through row 3. B3 retains both nonbreaking spaces; C3 becomes a leading space, A, three ordinary spaces, B and a trailing space. D3/E3 both return 65, because the second character is A in this longer input. F3 is 7, and G3 is FALSE.

Put =TRIM(C3) in C5 for A B, D5 =LEN(C5) for 3 and E5 =EXACT(C5,"A B") for TRUE. Replacement and ordinary-space normalization are separate operations; the displayed spacing alone cannot identify a codepoint.

Cleanup can destroy meaningful separation

Removing a tab or line break joins adjacent text. A tab-separated field A and B becomes AB under the control-removal model, not A B. If that separator carries meaning, decide whether a targeted replacement is needed before deletion. Do not apply a blanket cleanup to an entire workbook merely because some fields contain unwanted controls.

A zero-length formula result is different from a genuinely empty cell. Likewise, a visually unchanged string may still contain a nonbreaking space or one of the listed excluded controls. These examples do not establish every imported encoding, unusual whitespace rule, mixed-type conversion or exact error token.

Use the function syntax guide for your locale’s comma or semicolon argument separator and the cell-reference guide for cross-table references. CHAR constructs permitted characters, while CODE diagnoses a selected character; neither makes CLEAN a universal Unicode sanitizer.