Strip special characters from a string in JavaScript with a single replace() and a regex, or paste your text into the tool below to clean it instantly, no code required. Both keep letters, digits and spaces.
Use String.replace with a global, negated character class:
// Keep only letters, digits and spaces
const clean = text.replace(/[^A-Za-z0-9 ]/g, '');
// Keep word characters only (letters, digits, underscore)
const clean = text.replace(/[^\w]/g, '');
// Fold accents first (café -> cafe), then filter
const ascii = text.normalize('NFD').replace(/\p{Diacritic}/gu, '');
const clean = ascii.replace(/[^A-Za-z0-9 ]/g, '');
Prefer not to write code? The tool above does the same: it folds accents, then keeps only letters, digits and spaces.
Call replace with a global regex, like text.replace(/[^A-Za-z0-9 ]/g, ''), which keeps letters, digits and spaces. Normalise with normalize('NFKD') first if you also want to fold accents.
Use the negated class /[^A-Za-z0-9]/g so only alphanumerics remain. The g flag makes it replace every match, not just the first.
Same job in another tool: Python, JavaScript, Excel, Word or SQL.