| single |
# Python Slugify
Unicode-aware slug generation for Python, with explicit transliteration
choices.
[CI]
[PyPI]
[Maintained with Dojo]
## Quickstart
**[Version 9.0.0 and later] ship the modern algorithm.**
Legacy behavior remains the default; use `algorithm='modern'` for the
latest rules.
See the [migration guide] before changing persisted URLs or keys.
Install **python-slugify**, import **slugify**. Other similarly named
distributions are not this package.
```sh
python -m pip install --upgrade python-slugify
`
`python
from slugify import slugify
# Use the modern algorithm for the latest rules.
assert slugify("C'est déjà l'été.", algorithm='modern') ==
'c-est-deja-l-ete'
assert slugify('影師嗎', backend='text-unidecode', algorithm='modern')
== 'ying-shi-ma'
assert slugify('影師嗎', allow_unicode=True, algorithm='modern') ==
'影師嗎'
# Calling slugify() without algorithm uses the legacy pipeline (the old
default),
# kept unchanged for backward compatibility.
assert slugify("C'est déjà l'été.") == 'c-est-deja-l-ete'
`
`sh
slugify "Hello, world!"
# hello-world
printf 'Café' | python -m slugify --stdin
# cafe
slugify --regex-pattern '[^-a-z0-9_]+' '___This is a test___'
# ___this-is-a-test___
```
The examples above require python-slugify 9.0.0 or later. Python 3.10 or
newer is required.
## Python support
| Python | Release family |
| --- | --- |
| 2.7–3.5 | below 5 |
| 3.6 | 5–6 |
| 3.7–3.9 | 7–8 (check each release's Requires-Python) |
| 3.10+ | 9.x |
The configured release-9 test matrix covers CPython 3.10–3.14 and PyPy
3.11.
Configuration is not proof of a successful run; see [local verification].
Older applications can stay on a pinned 8.x release rather than upgrading
Python or regenerating slugs immediately.
## Backends and installation
| `backend` | Runtime selection | Installation |
| --- | --- | --- |
| `auto` (default) | Installed Unidecode first, otherwise text-unidecode |
Base install includes text-unidecode |
| `text-unidecode` | Only text-unidecode | Included in base install |
| `unidecode` | Only Unidecode | `python -m pip install
'python-slugify[unidecode]'` |
| `anyascii` | Only AnyASCII | `python -m pip install
'python-slugify[anyascii]'` |
Explicit selection never silently falls back. A missing selected module
raises `ModuleNotFoundError`.
Backend imports are lazy; `allow_unicode=True` bypasses transliteration
entirely.
**Extras add dependencies; they do not remove text-unidecode.** The
AnyASCII extra does not change the default backend.
There is no dependency-free installation extra in this release.
Transliteration is not translation, language detection, or
context-sensitive pronunciation.
Backends produce different slugs: for example `影師嗎` becomes
`ying-shi-ma` with text-unidecode/Unidecode,
but `yingshima` with AnyASCII. Pin both this package and your explicitly
chosen backend for stable persisted identifiers.
## API options
The original positional parameters remain in their original order. New
options are keyword-only.
```python
|