Unidecode

1.4.0 · active · verified Sun Mar 29

Unidecode is a Python library that provides ASCII transliterations of Unicode text. It converts non-ASCII Unicode characters into their closest ASCII approximations, which is useful for tasks like generating URL slugs or integrating with legacy systems. The current version is 1.4.0, with releases occurring as improvements to transliteration tables are made, rather than on a fixed schedule.

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use the `unidecode` function for basic transliteration and a common use case like generating URL slugs.

from unidecode import unidecode

# Basic transliteration
text_unicode = 'Łódź, 北京, Español'
text_ascii = unidecode(text_unicode)
print(f"Original: {text_unicode}")
print(f"Transliterated: {text_ascii}")

# Example for URL slug generation (common use case)
article_title = 'The "Café" where you can find "Piñatas"!'
slug = unidecode(article_title).replace(' ', '-').lower()
print(f"\nURL Slug: {slug}")

view raw JSON →