Skip to content

removeDiacritics

Removes diacritical marks (accents) from a string, e.g. 'café' → 'cafe'.

Works by Unicode-decomposing each character into its base letter plus combining marks ('é' → 'e' + a combining acute accent), then stripping the marks. Same technique already used internally by slugify.

Available since v3.0.0

import { removeDiacritics } from '@helpers4/string';
// or, from the all-in-one package (same code, one install):
import { removeDiacritics } from 'helpers4/string';
removeDiacritics(str: string): string
ParameterTypeDescription
strstringThe string to strip diacritics from

string — The string with diacritics removed

Useful for accent-insensitive search or generating ASCII-safe identifiers.

removeDiacritics('café')
// => 'cafe'

Only characters with combining diacritical marks are affected.

removeDiacritics('hello world')
// => 'hello world'

View source on GitHub