π Table of Contents
- Why Special Characters Cause Problems
- Method 1: SUBSTITUTE (Remove Specific Characters)
- Method 2: CLEAN Function (Non-Printable Characters)
- Method 3: REGEXREPLACE (Pattern-Based Removal)
- Method 4: Apps Script (Bulk Text Cleaning)
- Method 5: CleanSheet Automated Text Cleanup
- Ready-to-Use Formula Recipes
- Method Comparison
- FAQ
Special characters in Google Sheets can wreak havoc on your data. Whether it's curly quotes from a Word paste, hidden line breaks from a CSV import, emoji characters in form responses, or stray symbols from a web scrape β dirty text leads to broken formulas, failed lookups, and unreliable data.
In this comprehensive guide, you'll learn 5 methods to remove special characters and clean text in Google Sheets β from targeted formula fixes to fully automated cleanup solutions.
Why Special Characters Cause Problems
Special characters aren't just an aesthetic issue. They cause real, measurable problems in your spreadsheets:
- VLOOKUP failures: A hidden space or non-breaking space character makes "John" β "John " β causing lookup misses even though the values look identical.
- Broken CSV exports: Commas, quotes, and line breaks inside cells corrupt CSV file structure when exporting.
- API errors: Sending data with special characters to external services via Zapier, Make, or API integrations often causes encoding errors.
- Sorting inconsistencies: Symbols like @, #, and & sort before letters, pushing important rows to unexpected positions.
- Duplicate false positives: "O'Brien" and "O'Brien" (with a curly apostrophe) appear as two different entries but are the same person.
- Database import errors: Many databases reject characters like
\,", or null bytes during import.
Method 1: SUBSTITUTE (Remove Specific Characters)
The SUBSTITUTE function replaces specific characters with something else β or nothing at all (effectively removing them).
Basic Syntax:
=SUBSTITUTE(text, old_text, new_text)
Examples:
// Remove all hyphens
=SUBSTITUTE(A2, "-", "")
// "555-123-4567" β "5551234567"
// Remove dollar signs
=SUBSTITUTE(A2, "$", "")
// "$1,299.99" β "1,299.99"
// Replace curly quotes with straight quotes
=SUBSTITUTE(SUBSTITUTE(A2, CHAR(8220), CHAR(34)), CHAR(8221), CHAR(34))
// "Hello" β "Hello"
// Remove multiple characters (nested SUBSTITUTE)
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, "@", ""), "#", ""), "&", "")
// "Price: $99 @store #sale & more" β "Price: $99 store sale more"
Google Sheets supports nesting up to 30 SUBSTITUTE functions. For removing many characters, this works but becomes unreadable. For complex cleanup, use REGEXREPLACE (Method 3) instead.
Best for: Removing 1-3 specific, known characters.
Limitation: Gets messy when removing many different characters. Case-sensitive by default.
Method 2: CLEAN Function (Non-Printable Characters)
The CLEAN function removes non-printable ASCII characters (character codes 0-31) from text. These invisible characters often sneak in from data imports, copy-paste operations, and web scraping.
Syntax:
=CLEAN(text)
Common Use: Combine with TRIM
// Remove non-printable characters AND extra spaces
=TRIM(CLEAN(A2))
// " Hello\n\tWorld " β "Hello World"
What CLEAN Removes:
- Tab characters (
CHAR(9)) - Line feeds (
CHAR(10)) - Carriage returns (
CHAR(13)) - Null characters (
CHAR(0)) - All other ASCII control characters (codes 0-31)
CLEAN only removes ASCII characters 0-31. It does not remove non-breaking spaces (CHAR(160)), zero-width spaces, or Unicode special characters. For those, use =SUBSTITUTE(A2, CHAR(160), " ") combined with TRIM and CLEAN.
Best for: Cleaning imported data with hidden control characters.
Limitation: Only handles ASCII 0-31. Doesn't remove Unicode special characters, emoji, or visible symbols.
Method 3: REGEXREPLACE (Pattern-Based Removal)
REGEXREPLACE is the most powerful formula for text cleaning. It uses regular expressions to match and remove patterns of characters.
Syntax:
=REGEXREPLACE(text, regular_expression, replacement)
Essential Patterns:
// Remove ALL non-alphanumeric characters (keep letters, numbers, spaces)
=REGEXREPLACE(A2, "[^a-zA-Z0-9 ]", "")
// "Hello! @World #2026 (test)" β "Hello World 2026 test"
// Remove only numbers
=REGEXREPLACE(A2, "[0-9]", "")
// "Order #12345 shipped" β "Order # shipped"
// Remove only letters (keep numbers and symbols)
=REGEXREPLACE(A2, "[a-zA-Z]", "")
// "Order #12345 shipped" β " #12345 "
// Remove emoji and Unicode symbols
=REGEXREPLACE(A2, "[^\x00-\x7F]", "")
// "Hello π World! π" β "Hello World! "
// Remove HTML tags
=REGEXREPLACE(A2, "<[^>]+>", "")
// "Bold and italic" β "Bold and italic"
// Remove extra spaces (multiple spaces to single)
=REGEXREPLACE(A2, " +", " ")
// "Hello World" β "Hello World"
// Remove leading/trailing special characters
=REGEXREPLACE(A2, "^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$", "")
// "---Hello World!!!" β "Hello World"
Combine multiple cleaning steps in one formula:
=TRIM(CLEAN(REGEXREPLACE(SUBSTITUTE(A2, CHAR(160), " "), "[^\x20-\x7E]", "")))
This removes non-breaking spaces, non-printable characters, non-ASCII characters, and trims extra spaces β all in one shot.
Best for: Flexible, pattern-based text cleaning. The most versatile option.
Limitation: Regex syntax has a learning curve. Patterns can break with unexpected data.
Method 4: Apps Script for Bulk Text Cleaning
For cleaning entire columns or sheets at once β replacing formula results with clean values β use Apps Script.
Steps:
- Open your spreadsheet.
- Go to Extensions β Apps Script.
- Paste the following script:
function cleanSpecialCharacters() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var cleaned = 0;
for (var i = 0; i < values.length; i++) {
for (var j = 0; j < values[i].length; j++) {
if (typeof values[i][j] === 'string') {
var original = values[i][j];
// Remove non-printable characters
var clean = original.replace(/[\x00-\x1F\x7F]/g, '');
// Replace non-breaking spaces with regular spaces
clean = clean.replace(/\u00A0/g, ' ');
// Remove zero-width characters
clean = clean.replace(/[\u200B-\u200D\uFEFF]/g, '');
// Trim extra spaces
clean = clean.replace(/\s+/g, ' ').trim();
if (clean !== original) {
values[i][j] = clean;
cleaned++;
}
}
}
}
range.setValues(values);
SpreadsheetApp.getUi().alert(
'Done! Cleaned ' + cleaned + ' cells with special characters.'
);
}
- Click Run and authorize the script.
- The script scans every cell, removes hidden characters, and replaces the values in-place.
This script modifies cell values directly β there's no undo once it runs. Make a copy of your sheet before running. The script also overwrites formulas with their displayed values, so only run it on data cells, not formula cells.
Best for: One-time deep cleaning of large datasets with lots of hidden characters.
Limitation: Destructive, no undo, replaces formulas with values, requires coding.
Method 5: CleanSheet Automated Text Cleanup (Easiest)
For ongoing, automated text cleanup without formulas or scripts, CleanSheet provides no-code text formatting rules that run in the background.
Steps:
- Install CleanSheet from the Google Workspace Marketplace (free trial).
- Open your spreadsheet and launch CleanSheet from the Extensions menu.
- Create a text cleanup rule:
- Select the columns to clean
- Choose formatting actions: trim whitespace, fix capitalization, or clean text
- Set the scope (specific columns or entire sheet)
- Click "Preview" to see what changes will be made.
- Click "Run" to apply the cleanup.
- Enable scheduled auto-run to clean new data automatically.
CleanSheet runs in the background on Google's servers. Set up your text cleanup rules once, enable the scheduler, and every new row that arrives (from form submissions, API imports, or manual entry) gets cleaned automatically. No formulas to maintain, no scripts to debug.
Best for: Automated, ongoing text cleanup without formulas or coding.
Advantage: Preview, scheduled auto-run, handles whitespace and capitalization, no formulas required.
β¨ Clean Your Spreadsheet Text Automatically
Stop wrestling with REGEXREPLACE formulas. Install CleanSheet and let it clean your text data automatically. Free 2-day trial, no credit card required.
Install CleanSheet FreeReady-to-Use Formula Recipes
Copy-paste these formulas for common text cleaning scenarios:
| Task | Formula |
|---|---|
| Remove all special characters | =REGEXREPLACE(A2, "[^a-zA-Z0-9 ]", "") |
| Keep only numbers | =REGEXREPLACE(A2, "[^0-9]", "") |
| Remove line breaks | =SUBSTITUTE(SUBSTITUTE(A2, CHAR(10), " "), CHAR(13), " ") |
| Remove emoji | =REGEXREPLACE(A2, "[^\x00-\x7F]", "") |
| Remove HTML tags | =REGEXREPLACE(A2, "<[^>]+>", "") |
| Clean phone numbers | =REGEXREPLACE(A2, "[^0-9+]", "") |
| Full deep clean | =TRIM(CLEAN(REGEXREPLACE(SUBSTITUTE(A2,CHAR(160)," "),"[^\x20-\x7E]",""))) |
Method Comparison
| Method | Difficulty | Flexibility | Auto-Schedule | Preview |
|---|---|---|---|---|
| SUBSTITUTE | Easy | Low | β | β |
| CLEAN | Easy | Low | β | β |
| REGEXREPLACE | Hard | High | β | β |
| Apps Script | Hard | High | β οΈ Manual | β |
| CleanSheet | Easy | Medium | β | β |
Frequently Asked Questions
How do I remove special characters from text in Google Sheets?
Use the REGEXREPLACE formula: =REGEXREPLACE(A1, "[^a-zA-Z0-9 ]", "") to remove all non-alphanumeric characters. For specific characters, use SUBSTITUTE: =SUBSTITUTE(A1, "@", ""). For automated bulk cleanup, use CleanSheet's text formatting rules.
What is the CLEAN function in Google Sheets?
The CLEAN function removes non-printable ASCII characters (codes 0-31) from text. Syntax: =CLEAN(A1). It's useful for cleaning data imported from external sources that may contain hidden control characters like tabs, line breaks, and null bytes.
How do I remove line breaks from cells in Google Sheets?
Use the formula =SUBSTITUTE(SUBSTITUTE(A2, CHAR(10), " "), CHAR(13), " ") to replace both types of line breaks (LF and CR) with spaces. Combine with TRIM to remove any extra spaces: =TRIM(SUBSTITUTE(SUBSTITUTE(A2, CHAR(10), " "), CHAR(13), " ")).
Can I clean text in Google Sheets automatically on a schedule?
Yes! Use CleanSheet to set up automated text cleanup rules that run on a schedule (every 1, 6, 12, or 24 hours). It can trim whitespace, fix capitalization, and clean formatting automatically β even when your computer is off. No formulas to maintain or scripts to debug.