Member-only story

HOWTO: Remove diacritics (accents) from a text in Python

Wadie Skaf
2 min readDec 20, 2021

The most straightforward method for removing diacritics from a text in Python

Photo by Christina Morillo on Pexels

In many cases, it is necessary to generate diacritics-free (accent-free) text before performing a variety of operations: filename generation, database saving, keyword generation, etc., and it can be somewhat challenging to generate this type of text because some methods result in the loss of one or more characters rather than their replacement.

For this reason, I will provide you, dear reader, with a Python function that works with any language and smoothly removes accents. It only requires installing the “unicodedata” library:

pip install unicodedata2

And the function is as follows:

Thus, dear reader, the process is not as complicated as it may appear, and by utilizing this function, you will enjoy a life free of any sort of diacritics.

Enjoyed this article? If you’re looking to dive deeper or have any questions, feel free to reach out to me on Twitter and LinkedIn. I’m always open

--

--

Wadie Skaf
Wadie Skaf

Written by Wadie Skaf

AI expert, research scientist, and blogger pursuing a Ph.D. in Artificial Intelligence I write about Data Science, AI, and Python TIPS & TRICKS.

Responses (1)