CLEAN Function

CLEAN Function

CLEAN Function

Removes non-printable characters from text. Useful for imported data that contains hidden control characters.

ExcelClash Team
PUBLISHED

Summary

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)).

Purpose

Remove hidden control characters

Strips out non-printable characters that can make text behave unexpectedly.

Return Value

Cleaned text

Returns the same text without non-printable characters. If nothing needs to be removed, the output matches the input.

Syntax

=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.

Arguments

  • text - The text string or cell reference to clean.

CLEAN vs Other Functions

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),"").

Using CLEAN

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)).

  • Use TRIM(CLEAN(A1)) as a standard cleanup pattern for imported text.
  • Use SUBSTITUTE if the problem is a non-breaking space rather than a control character.
  • Use LEN before and after CLEAN when you want proof that something was removed.

Example 1 - Removing a Line Break from 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"
Check Answer
Challenge #1
Target: Sheet1!F1
Remove a Line Break

In cell F1, use CLEAN to remove all non-printable characters from A1. A1 contains text with a hidden line break.

Example 2 - Fixing Text from an Old System

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"
Check Answer
Challenge #2
Target: Sheet1!F2
Fix a Legacy Import

In cell F2, clean the text in B2 which was imported from an old system and contains a hidden control character.

Example 3 - Cleaning and Trimming in One Step

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
Check Answer
Challenge #3
Target: Sheet1!F3
Clean and Trim Together

In cell F3, combine TRIM and CLEAN on C3 to remove both hidden characters and extra spaces in one step.

Example 4 - Measuring Characters Before and After

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
Check Answer
Challenge #4
Target: Sheet1!F4
Check Length Before and After

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.

  • CLEAN removes ASCII control characters 0 to 31.
  • Use TRIM for extra spaces and SUBSTITUTE for CHAR(160).
  • Use LEN if you want to verify the cleanup result.

Conclusion Recap

  • Summary: CLEAN removes non-printable characters from text.
  • Syntax: =CLEAN(text).
  • Best partner: TRIM, because spaces and hidden characters often appear together.
  • Limitation: CLEAN does not remove non-breaking spaces such as CHAR(160).
  • Typical use: Fixing imported text before lookups, comparisons, and reporting.
Tactical Arena
Select Scenario:
Share CLEAN Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.