python-slugify

URL-safe slug generation from Unicode strings — converts any text to URL-friendly lowercase ASCII strings. python-slugify features: slugify() function, Unicode transliteration (é→e, ü→u, 中文→zhong-wen), max_length for truncation, separator parameter (default '-'), allow_unicode=True for Unicode-preserving slugs, lowercase=False to preserve case, stopwords list to remove common words, word_boundary for clean truncation at word boundaries, regex_pattern for custom character stripping, replacements for custom character mapping, and slugify_unicode() alternative. Handles Arabic, Chinese, Japanese, Cyrillic and 50+ languages.

Evaluated Mar 06, 2026 (0d ago) v8.x
Homepage ↗ Repo ↗ Developer Tools python slugify slug URL unicode transliterate text
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
92
/ 100
Is it safe for agents?
⚡ Reliability
90
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
80
Auth Simplicity
99
Rate Limits
99

🔒 Security

TLS Enforcement
92
Auth Strength
92
Scope Granularity
92
Dep. Hygiene
90
Secret Handling
92

Pure text processing library. slugify() output is safe for URLs — alphanumeric and hyphens only. Prevents path traversal: slugify('../../../etc/passwd') → 'etc-passwd' (safe). Still validate slugs against allowed patterns before using in file paths or SQL.

⚡ Reliability

Uptime/SLA
88
Version Stability
90
Breaking Changes
90
Error Recovery
90
AF Security Reliability

Best When

Generating URL-safe slugs from user-provided titles in any language — python-slugify handles Unicode correctly while other slug libraries fail on non-ASCII.

Avoid When

Unique ID generation (use uuid), filename sanitization (use pathvalidate), or when Django's django.utils.text.slugify is already available.

Use Cases

  • Agent URL slug — from slugify import slugify; title = 'Hello World! This is a Test.'; slug = slugify(title) — 'hello-world-this-is-a-test'; agent generates URL-safe slug from arbitrary text; punctuation removed; spaces become hyphens; lowercased
  • Agent Unicode transliteration — slug = slugify('Ångström & Ré:sümé') — 'angstrom-and-resume'; slug = slugify('中文标题') — 'zhong-wen-biao-ti'; agent handles international text; accented chars converted to ASCII equivalents; CJK transliterated to pinyin
  • Agent length-limited slug — slug = slugify('Very Long Title That Exceeds URL Length Limits', max_length=20, word_boundary=True) — 'very-long-title-that'; agent truncates at word boundary; word_boundary=True avoids cutting mid-word; max_length=50 for SEO-friendly URLs
  • Agent custom separator — slug = slugify('hello world', separator='_') — 'hello_world'; slug = slugify('hello world', separator='') — 'helloworld'; agent generates slugs for different contexts; underscore for Python identifiers; empty for compact URLs
  • Agent stopwords removal — slug = slugify('The Quick Brown Fox', stopwords=['the', 'a', 'an']) — 'quick-brown-fox'; agent removes common words for cleaner slugs; useful for SEO; stopwords compared case-insensitively

Not For

  • Database ID generation — slugs are not unique; for unique identifiers use uuid or nanoid
  • Filename sanitization — slugify removes too many characters for filenames; for filenames use pathvalidate
  • Full Unicode URL support — allow_unicode=True creates Unicode slugs but some systems don't support them; for full internationalization use URL encoding

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — text processing utility.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

python-slugify is MIT licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • slugify() may return empty string — slugify('!!!@@@###') returns '' — all non-alphanumeric input; agent code: check if slug is empty: slug = slugify(title) or 'untitled'; or add fallback ID: slug = slugify(title) or str(uuid4())[:8]; always validate slug is non-empty before using as URL
  • Slugs are not unique — slugify('Hello World') and slugify('hello-world') both return 'hello-world'; agent code for unique URLs: append ID: slug = f'{slugify(title)}-{obj.id}'; database: add unique constraint on slug field; ensure uniqueness before saving
  • max_length truncation may cut mid-word — max_length=20 without word_boundary=True may cut at any character; agent code: always use word_boundary=True with max_length: slugify(title, max_length=50, word_boundary=True); word_boundary finds last complete word within limit
  • import is 'slugify' not 'python_slugify' — pip install python-slugify; from slugify import slugify; package is 'python-slugify' but module is 'slugify'; agent code: do not confuse with 'slugify' package (different, less capable); verify: slugify('ü') should return 'u' not '?'
  • CJK transliteration requires optional dependency — python-slugify transliterates CJK via Unidecode; Unidecode is listed as optional; pip install python-slugify[unidecode] for CJK support; agent code for multilingual text: install with: pip install 'python-slugify[unidecode]'; without it, CJK chars are dropped
  • replacements applied before slugification — replacements=[('&', 'and'), ('@', 'at')] converts characters before Unicode transliteration and slug generation; agent code: define replacements in same order as expected output; replacements are case-sensitive; slugify('Tom & Jerry', replacements=[('&', 'and')]) → 'tom-and-jerry'

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for python-slugify.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered