Convert non-ASCII characters (umlauts, accents…) to their closest ASCII equivalent (for slug creation)

The easiest way I’ve found:

var str = "Rånades på Skyttis i Ö-vik";
var combining = /[\u0300-\u036F]/g; 

console.log(str.normalize('NFKD').replace(combining, ''));

For reference see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

Leave a Comment