Python Slugify: Robust Unicode Slug Generation in Python

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

Python Slugify: Robust Unicode Slug Generation in Python

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.

Repository Information

Analyzed by OSRepos on July 31, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

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 GitHub repository.

Installation

Installing Python Slugify is straightforward using pip:

pip install python-slugify

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

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:

from slugify import slugify

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

Handling Unicode Characters:

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:

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

Limiting Length and Word Boundaries:

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:

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:

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 test file.

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

Related repositories

Similar repositories that may be relevant next.

karpathy-llm-wiki: Build a Karpathy-Style LLM Knowledge Base

karpathy-llm-wiki: Build a Karpathy-Style LLM Knowledge Base

September 9, 2026

karpathy-llm-wiki is an Agent Skills-compatible tool that implements Karpathy's LLM Wiki idea, allowing users to build a durable knowledge base. It enables LLMs to maintain structured wiki pages by ingesting sources, compiling knowledge, and answering questions with citations. This project offers a robust alternative to traditional RAG for compounding knowledge over time.

llm-wikiknowledge-baseagent-skill
CQ: An Open Standard for Shared Agent Learning by Mozilla.ai

CQ: An Open Standard for Shared Agent Learning by Mozilla.ai

September 5, 2026

CQ is an open standard designed to prevent AI agents from repeatedly making the same mistakes by enabling them to persist, share, and query collective knowledge. It facilitates a structured exchange of ideas, allowing agents to learn from each other's experiences and accelerate development. This system helps agents avoid redundant debugging and discover solutions more efficiently.

agentsgopython
Otari: Self-Hosted OpenAI-Compatible LLM Gateway for 40+ Providers

Otari: Self-Hosted OpenAI-Compatible LLM Gateway for 40+ Providers

September 4, 2026

Otari, from Mozilla AI, is an open-source, self-hosted LLM gateway. It provides a single OpenAI-compatible endpoint to connect with over 40 model providers, offering features like virtual keys, budget enforcement, and usage tracking. This solution empowers users to manage their AI stack with greater control and flexibility.

ai-gatewayllmopenai-compatible
Agent Factory: Generate AI Agents with Natural Language Descriptions

Agent Factory: Generate AI Agents with Natural Language Descriptions

September 3, 2026

Agent Factory, developed by Mozilla-AI, is a powerful tool designed to generate AI agents and workflows. It allows users to describe tasks in natural language, which it then transforms into executable Python code for agentic workflows. Leveraging the Model Context Protocol (MCP) and the any-agent library, it simplifies the creation of complex AI solutions.

agentagentic-aicli

Source repository

Open the original repository on GitHub.

13 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️