# Python Slugify: Robust Unicode Slug Generation in Python

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/un33k-python-slugify
Generated for open source discovery and AI-assisted research.

Python Slugify is a powerful Python library designed to create clean, URL-friendly slugs from Unicode strings. It offers extensive customization options, including handling HTML entities, setting max lengths, and defining stopwords. This tool ensures your text is properly formatted for web use, supporting various languages and complex character sets.

GitHub: https://github.com/un33k/python-slugify
OSRepos URL: https://osrepos.com/repo/un33k-python-slugify

## Summary

Python Slugify is a powerful Python library designed to create clean, URL-friendly slugs from Unicode strings. It offers extensive customization options, including handling HTML entities, setting max lengths, and defining stopwords. This tool ensures your text is properly formatted for web use, supporting various languages and complex character sets.

## Topics

- python
- slugify
- unicode
- text-processing
- web-development
- utility
- seo

## Repository Information

Last analyzed by OSRepos: Fri Jul 31 2026 17:37:34 GMT+0100 (Western European Summer Time)
Detail views: 1
GitHub clicks: 0

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Python Slugify is a robust and highly customizable Python library designed to convert strings, especially those containing Unicode characters, into clean, URL-friendly "slugs." A slug is a simplified version of a title or name, typically used in URLs, that contains only letters, numbers, and hyphens. This library excels at handling complex character sets, ensuring your web content has consistent and readable identifiers.

It makes a best effort to create slugs from unicode strings while keeping it DRY. By default, it uses `text-unidecode` for its decoding needs, but also offers an alternative with `Unidecode` for those who prefer it, which can be installed as `python-slugify[unidecode]`. For more details, visit the official <a href="https://github.com/un33k/python-slugify" target="_blank">GitHub repository</a>.

## Installation

Installing Python Slugify is straightforward using pip:

bash
pip install python-slugify


If you prefer to use the `Unidecode` package for decoding, you can install it with the following command:

bash
pip install python-slugify[unidecode]


## Examples

Python Slugify provides a flexible `slugify` function with numerous options to tailor the output to your specific needs. Here are some common use cases:

**Basic Usage:**

python
from slugify import slugify

txt = "This is a test ---"
r = slugify(txt)
print(r)
# Output: this-is-a-test


**Handling Unicode Characters:**

python
txt = '???'
r = slugify(txt)
print(r)
# Output: ying-shi-ma

txt = 'C\'est déjà l\'été.'
r = slugify(txt)
print(r)
# Output: c-est-deja-l-ete

txt = 'Nín h?o. W? shì zh?ng guó rén'
r = slugify(txt)
print(r)
# Output: nin-hao-wo-shi-zhong-guo-ren

txt = '?????????'
r = slugify(txt)
print(r)
# Output: kompiuter


**Allowing Unicode in Slugs:**

python
txt = '???'
r = slugify(txt, allow_unicode=True)
print(r)
# Output: ???


**Limiting Length and Word Boundaries:**

python
txt = 'jaja---lol-méméméoo--a'
r = slugify(txt, max_length=9)
print(r)
# Output: jaja-lol

txt = 'jaja---lol-méméméoo--a'
r = slugify(txt, max_length=15, word_boundary=True)
print(r)
# Output: jaja-lol-a


**Custom Separators and Stopwords:**

python
txt = 'jaja---lol-méméméoo--a'
r = slugify(txt, max_length=20, word_boundary=True, separator=".")
print(r)
# Output: jaja.lol.mememeoo.a

txt = 'the quick brown fox jumps over the lazy dog'
r = slugify(txt, stopwords=['the'])
print(r)
# Output: quick-brown-fox-jumps-over-lazy-dog


**Custom Replacements:**

python
txt = '10 | 20 %'
r = slugify(txt, replacements=[['|', 'or'], ['%', 'percent']])
print(r)
# Output: 10-or-20-percent


For more examples and advanced usage, refer to the project's <a href="https://github.com/un33k/python-slugify/blob/master/test.py" target="_blank">test file</a>.

## Why Use It

Python Slugify stands out for several reasons, making it an excellent choice for developers needing robust slug generation:

*   **Comprehensive Unicode Support**: It effectively handles a wide array of international characters, converting them into readable ASCII equivalents or preserving them if `allow_unicode` is set.
*   **High Customizability**: With options for `max_length`, `word_boundary`, `separator`, `stopwords`, `regex_pattern`, `lowercase`, and `replacements`, you have fine-grained control over the generated slugs.
*   **Ease of Use**: The `slugify` function is intuitive and simple to integrate into any Python project.
*   **Command-Line Tool**: A convenient command-line utility is included, allowing for quick slug generation directly from your terminal.
*   **Active Maintenance**: The project is actively maintained, as indicated by its support matrix for various Python versions.

Whether you are building a blog, an e-commerce site, or any application that requires clean and SEO-friendly URLs, Python Slugify provides a reliable and flexible solution.

## Links

*   **GitHub Repository**: <a href="https://github.com/un33k/python-slugify" target="_blank">https://github.com/un33k/python-slugify</a>
*   **PyPI Project**: <a href="https://pypi.org/project/python-slugify/" target="_blank">https://pypi.org/project/python-slugify/</a>
*   **License**: <a href="https://github.com/un33k/python-slugify/blob/master/LICENSE" target="_blank">MIT License</a>
*   **Sponsor**: <a href="http://neekware.com" target="_blank">Neekware Inc.</a>