How to use 'javascript remove accents' in JavaScript

Every line of 'javascript remove accents' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1function removeAccents(str) {
2 var r = str.toLowerCase();
3 r = r.replace(new RegExp("[àáâãäå]", 'g'),"a");
4 r = r.replace(new RegExp("æ", 'g'),"ae");
5 r = r.replace(new RegExp("ç", 'g'),"c");
6 r = r.replace(new RegExp("[èéêë]", 'g'),"e");
7 r = r.replace(new RegExp("[ìíîï]", 'g'),"i");
8 r = r.replace(new RegExp("ñ", 'g'),"n");
9 r = r.replace(new RegExp("[òóôõö]", 'g'),"o");
10 r = r.replace(new RegExp("œ", 'g'),"oe");
11 r = r.replace(new RegExp("[ùúûü]", 'g'),"u");
12 r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
13 return r;
14}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

161export function removeAccentsUnicode(str : string) : string {
162 return str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
163}

Related snippets