Excel Clean Function

“excel clean function” comes up constantly, so this page leads with the exact answer, gives you a tool to try it on your own numbers, and only then explains the detail. Everything works in Excel on Windows and Mac and maps almost one-to-one to Google Sheets. Copy the answer above and get back to work, or read on to turn a one-off fix into something you never have to look up again.

Exact answer

In Excel: use =CLEAN(text) — it removes non-printable control characters, the invisible debris that survives a copy from a PDF or a mainframe export.

Syntax

=CLEAN(text)

Arguments

ArgumentDescription
textrequiredText to strip of non-printable characters (codes 0 to 31).

Related functions

TRIMSUBSTITUTELEN
ƒxData CleanerLive
Clean rows
3

1 duplicates · 1 blank rows removed · 0 replacements

Runs entirely in your browser — your data never leaves this page.
Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

What this does

CLEAN strips the first 32 ASCII control characters — line feeds, carriage returns, tabs and similar — from text. Those arrive with PDF copies, mainframe extracts and web pastes, and they are invisible on screen while breaking every comparison and lookup against the column. Its important limitation is the non-breaking space, character 160, which is not in the range CLEAN removes and is the single most common culprit in web-pasted data. Removing that needs SUBSTITUTE(A2, CHAR(160), " "). The full repair for imported text is therefore all three: TRIM, CLEAN and that SUBSTITUTE. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. Treat “excel clean function” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected formula shows up while it is still harmless. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That turns a text operation that turns messy entries into clean, usable data into a method you can reuse, explain, and defend when the workbook leaves your screen.

A worked example

Removing line breaks that a PDF paste left inside cells: =CLEAN(A2) collapses them out. The complete import repair: =TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " "))) handles control characters, non-breaking spaces and padding in one pass. Diagnosing what is left: =CODE(LEFT(A2,1)) reveals the first character's number. CLEAN removes the invisible debris that makes two identical-looking values refuse to match, which is the hardest data problem to diagnose without it. If there is any chance you will reuse this, drop it into a small template tab right now: a labelled input area on the left and the formula beside it, checked once against the tool above. Next time the same question comes up, the answer is a single paste away instead of a rebuild from memory.

In Google Sheets

If you are in Google Sheets rather than Excel, the good news is that the formula shown here is identical and the workflow barely changes — menus sit across the top instead of in a ribbon, and a few function names differ slightly, but anything you build here moves across with little or no rework. Nothing on this page is behind a login: the tool runs entirely in your browser, the formula is shown in full with one-click copy, and the steps work the same on Windows and Mac. That is the whole promise here — the exact answer, a way to prove it on your own numbers, and just enough context to make it stick. If you take one thing from this page on “excel clean function”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.

Common mistakes

  • Expecting CLEAN to remove non-breaking spaces; character 160 is outside its range and needs SUBSTITUTE.
  • Using CLEAN alone where TRIM was also needed — the two remove different things.
  • Cleaning a column and leaving the helper formulas live, so the result still depends on the dirty source.

Frequently asked questions

How do I remove line breaks from cells?

=CLEAN(A2) removes them, or =SUBSTITUTE(A2, CHAR(10), " ") replaces them with a space if you want the words separated.

Why is there still an invisible character after CLEAN?

It is probably a non-breaking space (character 160), which CLEAN does not touch. Use SUBSTITUTE(A2, CHAR(160), " ").

What is the difference between CLEAN and TRIM?

CLEAN removes non-printable control characters; TRIM removes extra spaces. Imported data usually needs both.