
Removes non-printable characters from text. Useful for imported data that contains hidden control characters.
The Excel CLEAN function removes non-printable characters from text. These hidden characters often appear in imported data and can interfere with lookups, comparisons, and formatting.
CLEAN removes characters with ASCII codes 0 to 31. It does not remove normal spaces, so it is often paired with TRIM. A common pattern is =TRIM(CLEAN(A1)).
Strips out non-printable characters that can make text behave unexpectedly.
Returns the same text without non-printable characters. If nothing needs to be removed, the output matches the input.
=CLEAN(text)
CLEAN takes one argument: the text or cell you want to clean. Excel checks the full string and removes non-printable characters wherever they appear.
CLEAN and TRIM are often used together, but they solve different problems. CLEAN removes hidden control characters. TRIM removes extra visible spaces. If web data contains a non-breaking space, you may also need SUBSTITUTE.
| Function | Primary Role | Typical Output | Use When |
|---|---|---|---|
CLEAN |
Remove non-printable characters | Cleaned text | Imported text contains hidden control characters |
TRIM |
Remove extra spaces | Trimmed text | Text has leading, trailing, or repeated spaces |
SUBSTITUTE |
Replace a specific character | Modified text | You need to remove a character CLEAN does not handle, such as CHAR(160) |
LEN |
Count characters | A number | You want to compare the text before and after cleaning |
One important limitation is that CLEAN does not remove the non-breaking space, often written as CHAR(160). That character is common in copied web data and looks like a normal space. If it remains, use =SUBSTITUTE(A1,CHAR(160),"").
CLEAN is most useful when text looks fine on screen but behaves strangely in formulas. Imported rows from PDFs, websites, and older systems often contain hidden characters that prevent exact matches or create unexpected line breaks.
In practice, CLEAN is often used in a helper column together with TRIM. If you want to confirm that hidden characters were removed, compare LEN(original) with LEN(CLEAN(original)).
TRIM(CLEAN(A1)) as a standard cleanup pattern for imported text.A line break inside a cell often makes the row look taller than expected. CLEAN removes that hidden character and returns a flat text string.
=CLEAN(A1) // Removes CHAR(10) from "Product
Name"
// Result: "ProductName"
In cell F1, use CLEAN to remove all non-printable characters from A1. A1 contains text with a hidden line break.
Older exports sometimes contain control characters that are invisible in the cell but still part of the value. CLEAN removes them without needing a separate rule for each code.
=CLEAN(B2) // Input: "Part" + CHAR(7) + "001"
// Result: "Part001"
In cell F2, clean the text in B2 which was imported from an old system and contains a hidden control character.
Many imported values contain both hidden characters and extra spaces. Wrapping CLEAN inside TRIM handles both problems in one formula.
=TRIM(CLEAN(C3)) // Removes hidden chars and extra spaces
=PROPER(TRIM(CLEAN(A1))) // Can also be combined with other text functions
In cell F3, combine TRIM and CLEAN on C3 to remove both hidden characters and extra spaces in one step.
Using LEN with CLEAN is a quick way to confirm that hidden characters were removed. If the count gets smaller, the original text contained non-printable characters.
=LEN(D4) // Count before cleaning
=LEN(CLEAN(D4)) // Count after cleaning
// The difference shows how many hidden characters were removed
In cell F4, use CLEAN on D4 and then LEN to see how many characters were removed. Formula: =LEN(CLEAN(D4)).
CLEAN checks the entire text string, not just the first character. If hidden characters appear at the beginning, middle, or end, CLEAN removes them all.
CHAR(160).CLEAN removes non-printable characters from text.=CLEAN(text).TRIM, because spaces and hidden characters often appear together.CHAR(160).Tell your friends about this post