Excel CLEAN Function: Remove Non-Printable Characters Complete Guide

June 9, 2025

Excel’s CLEAN function is an essential tool for data cleaning that removes non-printable characters from text strings. Whether you’re dealing with imported data, web scraping results, or legacy system exports, the CLEAN function helps eliminate invisible characters that can cause formatting issues and data processing errors.

What is the Excel CLEAN Function?

The CLEAN function removes the first 32 non-printable characters from text (ASCII codes 0-31), including line breaks, tabs, and other control characters. This function is particularly useful when working with data imported from external sources that may contain hidden formatting characters.

CLEAN Function Syntax

The syntax for Excel’s CLEAN function is straightforward:

=CLEAN(text)

Parameters:

  • text (required): The text string from which you want to remove non-printable characters. This can be a cell reference, text string, or formula result.

Understanding Non-Printable Characters

Non-printable characters are control characters that don’t display visually but can affect data processing. Common examples include:

  • Line Feed (LF) – ASCII code 10
  • Carriage Return (CR) – ASCII code 13
  • Tab character – ASCII code 9
  • Null character – ASCII code 0
  • Bell character – ASCII code 7
  • Backspace – ASCII code 8

These characters often appear when importing data from databases, web sources, or text files, causing unexpected formatting issues or preventing proper data analysis.

CLEAN Function Examples

Basic CLEAN Function Usage

Here’s a simple example of removing non-printable characters from a text string:

=CLEAN("Hello" & CHAR(10) & "World")

This formula removes the line feed character (CHAR(10)) and returns “HelloWorld”.

Cleaning Cell References

When working with data in cells, you can reference the cell containing the text:

=CLEAN(A1)

If cell A1 contains “Product Name” (with a tab character), the CLEAN function will return “Product Name” with the tab removed.

Cleaning Multiple Cells

To clean an entire column of data, you can use the CLEAN function with array formulas or apply it to a range:

=CLEAN(A1:A10)

This approach works in Excel 365 and Excel 2021 with dynamic arrays.

Advanced CLEAN Function Techniques

Combining CLEAN with TRIM

Often, you’ll want to remove both non-printable characters AND excess spaces. Combine CLEAN with TRIM for comprehensive text cleaning:

=TRIM(CLEAN(A1))

This formula first removes non-printable characters, then eliminates extra spaces.

CLEAN with SUBSTITUTE for Specific Characters

While CLEAN removes ASCII 0-31 characters, you might need to remove other specific characters. Combine CLEAN with SUBSTITUTE:

=SUBSTITUTE(CLEAN(A1), CHAR(160), " ")

This removes non-printable characters and replaces non-breaking spaces (CHAR(160)) with regular spaces.

Nested CLEAN Functions for Complex Data

For heavily corrupted data, you might need multiple cleaning steps:

=TRIM(CLEAN(SUBSTITUTE(SUBSTITUTE(A1, CHAR(160), " "), CHAR(194), "")))

Common Use Cases for CLEAN Function

1. Web Data Import

When importing data from web sources, HTML entities and control characters often contaminate the data. The CLEAN function helps prepare this data for analysis.

2. Database Export Cleaning

Database exports frequently contain line breaks and tab characters within fields. CLEAN removes these characters to maintain data integrity.

3. Text File Processing

CSV and TXT files from different systems may include various control characters that interfere with Excel’s processing capabilities.

4. Legacy System Data

Older systems often use control characters for formatting that become problematic in modern spreadsheet applications.

CLEAN Function Limitations

Understanding the limitations of the CLEAN function is crucial for effective use:

  • Limited Range: Only removes ASCII characters 0-31, not all non-printable characters
  • Preserves Printable Characters: Won’t remove characters like non-breaking spaces (ASCII 160)
  • No Unicode Support: Doesn’t handle Unicode control characters beyond the basic ASCII range
  • Single Parameter: Can only process one text string at a time

Alternative Functions for Text Cleaning

TRIM Function

Removes extra spaces but not non-printable characters:

=TRIM(A1)

SUBSTITUTE Function

Removes specific characters you define:

=SUBSTITUTE(A1, CHAR(10), "")

REGEX Function (Excel 365)

For advanced pattern matching and character removal:

=REGEX(A1, "[^\x20-\x7E]", "", "g")

Troubleshooting CLEAN Function Issues

Function Not Removing All Unwanted Characters

If characters persist after using CLEAN, they might be outside the ASCII 0-31 range. Use the CODE function to identify character codes:

=CODE(MID(A1, 1, 1))

Performance Issues with Large Datasets

For large datasets, consider using Power Query instead of formula-based cleaning for better performance.

Formula Not Working

Ensure your text parameter is valid and the cell contains actual text data, not numbers or other data types.

Best Practices for Using CLEAN Function

  • Test First: Always test the CLEAN function on a small sample before applying to large datasets
  • Combine Functions: Use CLEAN with TRIM and SUBSTITUTE for comprehensive cleaning
  • Document Changes: Keep original data intact and document cleaning procedures
  • Validate Results: Check cleaned data to ensure important information wasn’t accidentally removed
  • Consider Automation: For repetitive tasks, consider creating custom VBA functions or using Power Query

CLEAN Function in Different Excel Versions

The CLEAN function is available in all modern Excel versions:

  • Excel 365: Full support with dynamic arrays
  • Excel 2021: Complete functionality
  • Excel 2019: Standard support
  • Excel 2016: Basic functionality
  • Earlier Versions: Limited to single-cell processing

Practical Example: Cleaning Imported Customer Data

Consider a scenario where you’ve imported customer data with various formatting issues:

Original Data (A1) CLEAN Formula (B1) Result
John
Smith
=TRIM(CLEAN(A1)) John Smith
Product ABC =CLEAN(A1) Product ABC
Data Export =TRIM(CLEAN(A1)) Data Export

Conclusion

The Excel CLEAN function is a powerful tool for removing non-printable characters from text data. While it has limitations, understanding its proper usage and combining it with other text functions creates robust data cleaning solutions. Whether you’re processing imported data, cleaning web scraping results, or preparing data for analysis, the CLEAN function should be an essential part of your Excel toolkit.

Remember to always test your cleaning formulas on sample data first, and consider the specific requirements of your dataset when choosing between CLEAN and alternative cleaning methods. With proper implementation, the CLEAN function will help maintain data quality and prevent formatting issues in your Excel workbooks.