Generatore di Slug Python

Generate SEO-friendly URL slugs for your Python projects instantly — no pip install needed to preview results. Whether you use Django, Flask, or FastAPI, a clean slug turns a title like "Merhaba Dünya!" into "merhaba-dunya". In Django, prefer SlugField with unique=True and generate values in the model save() method rather than in views, so admin-created and API-created objects behave identically; note that Django's built-in slugify() strips non-ASCII characters entirely unless you pass allow_unicode=True, which is why titles in Turkish, German or Ukrainian often need a transliteration step first — exactly what the python-slugify package (and this tool) handles with sensible language mappings. Flask and FastAPI have no built-in helper, so most teams vendor a 10-line function or depend on python-slugify; the standard-library variant below avoids the dependency at the cost of cruder Unicode handling. Common gotchas: forgetting to lowercase before comparing uniqueness, double hyphens after emoji removal, and slugs that collide after truncation to a database column limit. Paste your text above to see the exact output, compare separator and casing options, then copy the Python code below into your project.

from slugify import slugify  # pip install python-slugify

title = "Merhaba Dünya! SEO Friendly URL"
print(slugify(title))  # merhaba-dunya-seo-friendly-url

# Standard-library alternative (no dependency)
import re, unicodedata

def slugify_basic(text: str) -> str:
    text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode()
    text = re.sub(r'[^\w\s-]', '', text).strip().lower()
    return re.sub(r'[-\s]+', '-', text)