{"name":"Python Slugify: Robust Unicode Slug Generation in Python","description":"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","url":"https://osrepos.com/repo/un33k-python-slugify","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/un33k-python-slugify","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/un33k-python-slugify.md","json":"https://osrepos.com/repo/un33k-python-slugify.json","topics":["python","slugify","unicode","text-processing","web-development","utility","seo"],"keywords":["python","slugify","unicode","text-processing","web-development","utility","seo"],"stars":null,"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.","content":"## Introduction\n\nPython 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.\n\nIt 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>.\n\n## Installation\n\nInstalling Python Slugify is straightforward using pip:\n\nbash\npip install python-slugify\n\n\nIf you prefer to use the `Unidecode` package for decoding, you can install it with the following command:\n\nbash\npip install python-slugify[unidecode]\n\n\n## Examples\n\nPython Slugify provides a flexible `slugify` function with numerous options to tailor the output to your specific needs. Here are some common use cases:\n\n**Basic Usage:**\n\npython\nfrom slugify import slugify\n\ntxt = \"This is a test ---\"\nr = slugify(txt)\nprint(r)\n# Output: this-is-a-test\n\n\n**Handling Unicode Characters:**\n\npython\ntxt = '???'\nr = slugify(txt)\nprint(r)\n# Output: ying-shi-ma\n\ntxt = 'C\\'est déjà l\\'été.'\nr = slugify(txt)\nprint(r)\n# Output: c-est-deja-l-ete\n\ntxt = 'Nín h?o. W? shì zh?ng guó rén'\nr = slugify(txt)\nprint(r)\n# Output: nin-hao-wo-shi-zhong-guo-ren\n\ntxt = '?????????'\nr = slugify(txt)\nprint(r)\n# Output: kompiuter\n\n\n**Allowing Unicode in Slugs:**\n\npython\ntxt = '???'\nr = slugify(txt, allow_unicode=True)\nprint(r)\n# Output: ???\n\n\n**Limiting Length and Word Boundaries:**\n\npython\ntxt = 'jaja---lol-méméméoo--a'\nr = slugify(txt, max_length=9)\nprint(r)\n# Output: jaja-lol\n\ntxt = 'jaja---lol-méméméoo--a'\nr = slugify(txt, max_length=15, word_boundary=True)\nprint(r)\n# Output: jaja-lol-a\n\n\n**Custom Separators and Stopwords:**\n\npython\ntxt = 'jaja---lol-méméméoo--a'\nr = slugify(txt, max_length=20, word_boundary=True, separator=\".\")\nprint(r)\n# Output: jaja.lol.mememeoo.a\n\ntxt = 'the quick brown fox jumps over the lazy dog'\nr = slugify(txt, stopwords=['the'])\nprint(r)\n# Output: quick-brown-fox-jumps-over-lazy-dog\n\n\n**Custom Replacements:**\n\npython\ntxt = '10 | 20 %'\nr = slugify(txt, replacements=[['|', 'or'], ['%', 'percent']])\nprint(r)\n# Output: 10-or-20-percent\n\n\nFor 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>.\n\n## Why Use It\n\nPython Slugify stands out for several reasons, making it an excellent choice for developers needing robust slug generation:\n\n*   **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.\n*   **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.\n*   **Ease of Use**: The `slugify` function is intuitive and simple to integrate into any Python project.\n*   **Command-Line Tool**: A convenient command-line utility is included, allowing for quick slug generation directly from your terminal.\n*   **Active Maintenance**: The project is actively maintained, as indicated by its support matrix for various Python versions.\n\nWhether 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.\n\n## Links\n\n*   **GitHub Repository**: <a href=\"https://github.com/un33k/python-slugify\" target=\"_blank\">https://github.com/un33k/python-slugify</a>\n*   **PyPI Project**: <a href=\"https://pypi.org/project/python-slugify/\" target=\"_blank\">https://pypi.org/project/python-slugify/</a>\n*   **License**: <a href=\"https://github.com/un33k/python-slugify/blob/master/LICENSE\" target=\"_blank\">MIT License</a>\n*   **Sponsor**: <a href=\"http://neekware.com\" target=\"_blank\">Neekware Inc.</a>","metrics":{"detailViews":1,"githubClicks":0},"dates":{"published":null,"modified":"2026-07-31T16:37:34.000Z"}}