Python Slugify
raw JSON → 8.0.4 verified Tue May 12 auth: no python install: verified quickstart: verified
Python-slugify is an actively maintained library that generates URL-friendly slugs from strings, with robust Unicode support. It is designed to create clean, human-readable, and SEO-friendly slugs by converting text, handling special characters, and replacing spaces. The library sees regular updates, with an average release cycle of approximately 71 days.
pip install python-slugify Common errors
error ModuleNotFoundError: No module named 'python_slugify' ↓
cause The user attempted to import the library using 'python_slugify' or 'python-slugify' instead of the correct package name, which is 'slugify'.
fix
Use
from slugify import slugify or import slugify to correctly import the library. error TypeError: 'module' object is not callable ↓
cause The user imported the `slugify` module directly using `import slugify` and then attempted to call the module itself as a function, instead of calling the `slugify` function provided within the module.
fix
Import the function directly using
from slugify import slugify and then call slugify("my string"), or if using import slugify, call slugify.slugify("my string"). error TypeError: expected string or bytes-like object ↓
cause The `slugify` function received an input that was not a string or bytes-like object (e.g., an integer, list, or None) instead of the required text.
fix
Ensure the input passed to the
slugify function is always a string, converting other types using str() if needed (e.g., slugify(str(my_number))). Warnings
gotcha There is a separate, older Python 2-only package also named `slugify` on PyPI. Installing `pip install slugify` will give you the wrong package. Always use `pip install python-slugify` to ensure you get the correct, actively maintained Python 3 library, as both packages use `from slugify import slugify` for import. ↓
fix Ensure `pip uninstall slugify` is run if the wrong package was installed, then `pip install python-slugify`. If possible, avoid installing both packages in the same environment.
breaking Python 3.6 support was dropped in version 7.0.0. For the latest versions (8.x.x), the minimum required Python version is 3.10. Older Python versions should use earlier library releases. ↓
fix Upgrade your Python interpreter to 3.10 or newer, or pin `python-slugify` to a version compatible with your Python environment (e.g., `<7.0.0` for Python 3.6).
gotcha The optional `Unidecode` dependency (installed via `pip install python-slugify[unidecode]`) is GPL licensed. If your project's license is incompatible with GPL, ensure you do not install this extra. The default `text-unidecode` dependency is permissively licensed. ↓
fix If GPL license is a concern, do not install `python-slugify[unidecode]`. The package works with the default `text-unidecode` which is permissively licensed.
breaking The behavior of the `regex_pattern` parameter was inverted in version 6.0.1. It now defines characters to be *disallowed* rather than *allowed*. This changes how custom character filtering works. ↓
fix Review and update any custom `regex_pattern` configurations to align with the new 'disallowed characters' logic.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.13s 18.2M
3.10 slim (glibc) - - 0.14s 19M
3.11 alpine (musl) - - 0.17s 20.0M
3.11 slim (glibc) - - 0.15s 21M
3.12 alpine (musl) - - 0.14s 11.9M
3.12 slim (glibc) - - 0.15s 12M
3.13 alpine (musl) - - 0.10s 11.5M
3.13 slim (glibc) - - 0.15s 12M
3.9 alpine (musl) - - 0.07s 17.7M
3.9 slim (glibc) - - 0.08s 18M
Imports
- slugify wrong
from slugify import slugifycorrectfrom slugify import slugify
Quickstart verified last tested: 2026-04-23
from slugify import slugify
# Basic usage
text = "This is a Test String with Unicode: Lörem Ipsüm!"
slug = slugify(text)
print(f"Basic Slug: {slug}")
# Custom separator
slug_with_underscore = slugify(text, separator='_')
print(f"Slug with underscore: {slug_with_underscore}")
# Max length
short_slug = slugify("A very very long title indeed", max_length=10)
print(f"Short Slug: {short_slug}")
# Keep unicode characters (requires allow_unicode=True)
unicode_slug = slugify("你好世界", allow_unicode=True)
print(f"Unicode Slug: {unicode_slug}")