Skip to content

removeAccents

Removes accents and diacritical marks from a string.

Syntax

typescript
removeAccents(str: string): string

Parameters

ParameterTypeDescription
strstringThe input string.

Returns

TypeDescription
stringThe string without accents or diacritical marks.

Example

typescript
removeAccents("ação"); // "acao"
removeAccents("café"); // "cafe"
removeAccents("Olá, mundo!"); // "Ola, mundo!"

Notes

  • Throws TypeError if the argument is not a string.
  • Uses Unicode normalization (NFD) to separate characters and removes diacritics with a regular expression.

References

Released under the MIT License.