Strip hidden characters and non-printing breaks in Excel

Remove hard carriage returns, non-breaking spaces, and invisible ASCII artifacts that break lookups. Use this after copying data from web forms or PDFs.

Text prompt for ChatGPT and Claude

You get: The master cleaning formula, step-by-step breakdown and verification formula

Prompt

Prompt
Act as an Excel formulas expert. Provide a formula solution to sanitize text strings corrupted by invisible control characters, non-breaking spaces, and embedded line breaks that cause VLOOKUP and XLOOKUP formulas to fail.

- Remove non-breaking spaces (ASCII character 160), carriage returns (CHAR 13), and line feeds (CHAR 10).
- Eliminate accidental leading, trailing, and duplicate middle spaces.
- Keep standard alphanumeric characters, punctuation, and visible symbols intact.
- Show how to test that the string is truly clean and formula-ready.

Output format:
- The master cleaning formula: The single formula to apply to raw cells.
- Step-by-step breakdown: What each wrapped function removes.
- Verification formula: A secondary formula to confirm hidden characters are gone.

My pasted raw text samples are below:

Example output

Cleaning hidden characters from text in ExcelThree nested functions applied to cell A2
  1. SUBSTITUTE non-breaking spacesStep 1Swaps CHAR(160) from web nbsp with normal spaces
  2. CLEAN control charactersStep 2Strips ASCII 0-31, including line feeds and carriage returns
  3. TRIM extra spacesStep 3Removes leading, trailing and repeated spaces
  4. Verify with EXACTCheckTRUE means the text is ready for exact lookups

Example for: web-scraped inventory SKUs failing exact XLOOKUP matches

The master cleaning formula

Assuming raw text is in cell A2:
=TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " ")))

For Mac Excel users, include CHAR(202) as well:
=TRIM(CLEAN(SUBSTITUTE(SUBSTITUTE(A2, CHAR(160), " "), CHAR(202), " ")))

Step-by-step breakdown
  1. SUBSTITUTE(A2, CHAR(160), " "): Swaps web non-breaking spaces (HTML  ) with standard keyboard spaces. CLEAN and TRIM ignore ASCII 160 by default, so this step is mandatory.
  2. CLEAN(...): Strips all 32 non-printable system control characters (ASCII 0 through 31), including line feeds (CHAR(10)) and carriage returns (CHAR(13)).
  3. TRIM(...): Removes standard leading and trailing spaces, and reduces internal multiple consecutive spaces down to a single space.
Verification formula

Enter this in an adjacent column to confirm the clean string has no non-standard characters left:
=EXACT(B2, TRIM(CLEAN(B2)))

If this returns TRUE, the text is completely free of hidden control codes and ready for exact lookups.

Written by AI from this prompt. Your results will vary.

Paste your problematic values or an excerpt of failing lookup data into ChatGPT, Claude, or Gemini. If lookups still fail, ask the model for an exact LEN comparison formula to catch remaining ghost characters.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Excel & Spreadsheets

Clean phone numbers and postal codes using Excel formulas

Transform irregular contact details into uniform formats for clean CRM imports. Use this whenever raw exports mix dashes, dots, spaces, or leading zeroes.

Excel & Spreadsheets

Pick XLOOKUP, VLOOKUP or INDEX MATCH and Get the Exact Formula

You get one recommended lookup method for your Excel version and data layout, a paste-ready formula, and clear handling for values that have no match.

Excel & Spreadsheets

Deduplicate spreadsheet rows keeping latest entry

Finds duplicate records in your data and generates clean formulas or step-by-step instructions to keep only the newest record.

Excel & Spreadsheets

Parse Unstructured Text into Clean Excel Columns

This prompt generates specific Excel formulas to split messy text strings into organized columns while handling edge cases like missing delimiters.

Excel & SpreadsheetsGemini

Write Google Sheets REGEX Formulas to Extract and Clean Text

Get ready-to-paste REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH formulas for Google Sheets with a token-by-token breakdown.

Excel & Spreadsheets

Build a Fuzzy Matching Workflow for Data Reconciliation

Get a structured workflow to reconcile inconsistent vendor or customer names using Excel formulas and data cleaning steps to identify matches and manual audit needs.