Generate a Slug
A slug generator converts text into a URL-friendly string by removing special characters, replacing spaces with hyphens, and lowercasing everything. Paste a single title or multiple lines for batch conversion.
Examples
See how different inputs are converted to clean slugs:
How Slugification Works
Slugification converts any text into a URL-safe string. Here is the step-by-step process this tool follows:
- Unicode normalization (NFKD): Decomposes accented characters into base letter + diacritic. For example,
ébecomese+ combining accent mark. - Strip diacritics: Remove combining marks (accents, umlauts, tildes), leaving plain ASCII letters.
- Lowercase: Convert all characters to lowercase for URL consistency.
- Remove non-alphanumeric: Replace any character that isn't a letter, number, or space with a space.
- Remove stop words (optional): Strip common filler words like "the", "a", "is", "on".
- Replace spaces: Swap spaces for the chosen separator (hyphen or underscore).
- Collapse consecutive separators: Turn
--into-. - Trim separators: Remove leading and trailing separators.
- Truncate (optional): Cut to the max length at a word boundary to avoid broken words.
How Characters Are Handled
| Input | Result | Why |
|---|---|---|
| Spaces | - or _ |
Replaced with your chosen separator |
| UPPERCASE | lowercase |
URLs are case-sensitive on some servers; lowercase is the standard |
| Accents (é, ü, ñ) | e, u, n |
Normalized to ASCII equivalents via NFKD decomposition |
| Punctuation (!?.,:;) | removed | Not safe or meaningful in slugs |
| Ampersand (&) | removed | Has special meaning in URLs (query parameter separator) |
| Multiple spaces | Single - |
Collapsed to avoid double separators |
| Numbers (0-9) | kept | Numbers are URL-safe |
| Emoji (🎉, 🚀) | removed | Not supported in standard URL paths |
Best Practices for URL Slugs
✓ Use Hyphens, Not Underscores
Search engines treat hyphens as word separators. "blue-shoes" = two words. "blue_shoes" = one word. Hyphens are the web standard.
✓ Keep It Short
Aim for 3-5 words. Remove filler words like "the", "and", "a" when they don't add meaning. Google truncates URLs at ~60 characters in search results.
✓ Include Keywords
Put your main keyword in the slug. "/running-shoes-guide" tells search engines and users what the page is about — "/article-12345" does not.
✓ Be Descriptive
Users should understand the page content from the URL alone. Clear slugs improve click-through rates in search results and social shares.
✗ Avoid Keyword Stuffing
"/seo-tips-seo-guide-seo-tutorial" is spammy. One natural mention of your target keyword is enough.
✗ Avoid Deep Nesting
"/blog/2024/tech/js/arrays/methods" is too deep. Prefer flat structures: "/blog/javascript-array-methods".
✗ Avoid Dates (Usually)
"/blog/2024/01/seo-tips" becomes outdated. Use dateless slugs for evergreen content. Exception: news sites where dates provide context.
✗ Don't Change Published Slugs
Changing a slug breaks existing links and loses rankings. If you must, set up a 301 redirect from the old URL to the new one.
Slug Conventions by Platform
Different platforms handle slugs in slightly different ways. Here is how major CMS and frameworks generate slugs:
| Platform | Separator | Max Length | Stop Words | Notes |
|---|---|---|---|---|
| WordPress | - |
~200 chars | Not removed | Auto-generates from title; editable before publish |
| Django | - |
50 chars (default SlugField) | Not removed | Uses slugify() from django.utils.text |
| Ruby on Rails | - |
No default limit | Not removed | parameterize method on String |
| Next.js / Gatsby | - |
No default limit | Not removed | Typically derived from filename or frontmatter |
| Medium | - |
~5-8 words | Some removed | Appends a random hash suffix for uniqueness |
| Shopify | - |
~255 chars | Not removed | Called "handle"; auto-generated from product title |
Regardless of platform, the same core rules apply: lowercase, hyphens, no special characters, and keep it short.
How to Slugify in Code
If you need slug generation in your application, here are minimal implementations for common languages:
function slugify(text) {
return text
.normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9\s-]/g, '')
.replace(/[\s-]+/g, '-')
.replace(/^-+|-+$/g, '');
}
// slugify("Café & Résumé!") → "cafe-resume"
import re, unicodedata
def slugify(text):
text = unicodedata.normalize('NFKD', text)
text = text.encode('ascii', 'ignore').decode('ascii')
text = text.lower().strip()
text = re.sub(r'[^a-z0-9\s-]', '', text)
text = re.sub(r'[\s-]+', '-', text)
return text.strip('-')
# slugify("Café & Résumé!") → "cafe-resume"
function slugify(string $text): string {
$text = transliterator_transliterate(
'Any-Latin; Latin-ASCII; Lower()', $text
);
$text = preg_replace('/[^a-z0-9\s-]/', '', $text);
$text = preg_replace('/[\s-]+/', '-', $text);
return trim($text, '-');
}
// slugify("Café & Résumé!") → "cafe-resume"
For production use, consider established libraries: slugify (npm), python-slugify (PyPI), or cocur/slugify (Composer). They handle edge cases like CJK characters, language-specific transliteration, and custom replacement maps.
Common Use Cases
- Blog posts: Turn article titles into readable URLs —
/blog/javascript-array-methods - Product pages: Create clean URLs from product names —
/products/wireless-bluetooth-headphones - Category pages: Generate consistent category slugs —
/categories/outdoor-gear - File naming: Convert document titles to safe filenames —
project-proposal-2024.pdf - Database keys: Create human-readable identifiers for records
- API endpoints: Design RESTful resource paths —
/api/v1/user-profiles - Anchor links: Generate IDs for heading anchors —
#getting-started - CSS class names: Derive class names from dynamic content (using underscore separator)
Common Mistakes
- Keyword stuffing:
/seo-tips-seo-guide-seo-tutorial-seo-helplooks spammy to both search engines and users. Use your keyword once, naturally. - Using IDs only:
/products/12345tells nobody what the page is about. Always include a descriptive slug. - Including file extensions:
/about-us.htmlis unnecessary on modern web servers. Use/about-usinstead. - Not handling accents: URLs with raw accented characters like
/café-menuget percent-encoded into/caf%C3%A9-menu, which is ugly and harder to share. - Trailing slashes inconsistency:
/aboutand/about/can be treated as different URLs. Pick one convention and stick with it. Use canonical URLs to prevent duplicates. - Mixed case:
/About-Usand/about-usmay resolve differently on case-sensitive servers (most Linux servers). Always use lowercase.
Frequently Asked Questions
What is a URL slug?
A URL slug is the part of a web address that identifies a specific page in a human-readable format. In example.com/how-to-bake-bread, the slug is how-to-bake-bread. Slugs use lowercase letters, numbers, and hyphens instead of spaces or special characters.
Why are slugs important for SEO?
Descriptive slugs help search engines understand page content. A slug like /best-running-shoes-2024 signals relevance better than /post?id=847. Users are also more likely to click links with readable URLs in search results. Google has confirmed that keywords in URLs are a minor ranking factor.
Should I use hyphens or underscores?
Use hyphens (-) for URL slugs. Google's algorithms treat hyphens as word separators but treat underscores as joiners. For filenames or programming identifiers, underscores are sometimes preferred.
How long should a slug be?
Keep slugs under 60 characters and 3-5 words when possible. Shorter slugs are easier to read, share, and remember. Google truncates URLs in search results at approximately 60 characters. Remove unnecessary filler words while keeping the meaning clear.
What is the difference between a slug and a URL?
A URL is the complete web address: https://example.com/blog/my-article. A slug is the human-readable identifier at the end: my-article. The slug is one component of the URL path, alongside the protocol, domain, and any directory structure.
How do I handle accented characters?
Convert accented characters to their ASCII equivalents: é → e, ü → u, ñ → n. This process is called transliteration. It uses Unicode normalization (NFKD decomposition) to separate base characters from diacritical marks, then strips the marks.
Should I remove stop words from slugs?
It depends on context. Stop words like "a", "the", "is", and "for" can be removed to shorten slugs. how-to-create-a-url-slug becomes create-url-slug. Remove them if the slug is too long, but keep them if removal makes the slug confusing or changes the meaning.
Can I change a slug after publishing?
You can, but changing a slug creates a new URL, which breaks existing links and can lose search rankings. If you must change it, set up a 301 redirect from the old URL to the new one. This tells search engines the page has permanently moved and passes most ranking signals to the new URL.
What characters are allowed in slugs?
For maximum compatibility, limit slugs to: lowercase letters (a-z), numbers (0-9), and hyphens (-). While URLs technically support many more characters via percent-encoding, clean ASCII slugs are easier to read, share, and type.
What is the difference between a slug and kebab-case?
They are structurally similar — both use lowercase words separated by hyphens. The difference is context. "Slug" refers to a URL-friendly page identifier (a web concept), while "kebab-case" is a general naming convention used in programming for variables, CSS classes, and file names.
How does this slug generator handle emoji?
Emoji are removed during slugification because they are not part of the ASCII character set and would be percent-encoded in URLs. A title like "Best Tools 🚀" becomes best-tools.
Does this tool store my text?
No. All processing happens in your browser using JavaScript. Your text is never sent to any server. You can verify this by using the tool offline after the page loads.
Related Tools
- URL Encoder/Decoder — encode and decode special characters in URLs
- Meta Tag Generator — create SEO meta tags for your pages
- SERP Preview Tool — preview how your URL and title appear in search results
- Text Case Converter — convert text between camelCase, snake_case, and more
- Character & Word Counter — check slug and title length
Privacy & Limitations
- Client-side only. No data is sent to any server. No cookies, no tracking of text entered.
- ASCII transliteration only. This tool converts accented Latin characters (é, ü, ñ, etc.) to ASCII equivalents. It does not transliterate non-Latin scripts (Chinese, Arabic, Cyrillic, etc.) — those characters are removed. For non-Latin slugs, use language-specific slugify libraries.
- No uniqueness check. This tool generates slugs from text but does not check whether the slug already exists on your website. Your CMS or application should handle uniqueness (typically by appending a number:
my-post-2).
Related Tools
View all toolsAnagram Checker
Check if two words or phrases are anagrams
Word Counter
Count words, characters, and sentences
Keyword Density Calculator
Analyze keyword frequency and density for SEO
Text Case Converter
Convert text to upper, lower, title, or sentence case
Reading Time Estimator
Estimate reading time from word count
Email Address Extractor
Extract email addresses from text
Slug Generator FAQ
What is a URL slug?
A URL slug is the part of a web address that identifies a specific page in a readable format. For example, in 'example.com/how-to-bake-bread', the slug is 'how-to-bake-bread'. Slugs use lowercase letters, numbers, and hyphens instead of spaces or special characters.
Why are URL slugs important for SEO?
URL slugs help search engines understand page content. A descriptive slug like '/best-running-shoes-2024' tells both users and search engines what the page is about, which can improve click-through rates and rankings. Google has confirmed that keywords in URLs are a minor ranking factor.
Should I use hyphens or underscores in slugs?
Use hyphens (-) for URL slugs. Google treats hyphens as word separators but treats underscores as word joiners. So 'blue-shoes' is read as two words, while 'blue_shoes' is read as one word. Hyphens are the standard for web URLs.
How long should a URL slug be?
Keep slugs between 3-5 words (50-60 characters). Short slugs are easier to read, share, and remember. Remove filler words like 'the', 'and', 'a' when they don't add meaning. Google truncates URLs in search results at around 60 characters.
What is the difference between a slug and a URL?
A URL is the full web address (e.g., 'https://example.com/blog/my-article'). A slug is just the human-readable part at the end that identifies the specific page ('my-article'). The slug is one component of the URL, alongside the protocol, domain, and path.
How do I handle accented characters in slugs?
Accented characters like é, ü, or ñ should be converted to their ASCII equivalents (e, u, n). This is called transliteration. Most slug generators, including this one, handle this automatically using Unicode normalization (NFKD decomposition) to strip diacritics.
Should I remove stop words from slugs?
It depends. Stop words (a, the, is, on, for, etc.) can be removed to shorten slugs. 'how-to-create-a-url-slug' becomes 'create-url-slug'. Remove them if the slug is too long, but keep them if removal changes the meaning or makes the slug hard to read.
Can I change a slug after publishing?
You can, but it creates a new URL, which can break existing links and lose search rankings. If you must change a slug, set up a 301 redirect from the old URL to the new one. This tells search engines and users that the page has permanently moved.
What characters are allowed in URL slugs?
For maximum compatibility and readability, limit slugs to lowercase letters (a-z), numbers (0-9), and hyphens (-). Technically URLs support more characters via percent-encoding, but readable ASCII slugs are best for SEO and usability.
How does slugification work?
Slugification converts text to a URL-safe string in several steps: (1) normalize Unicode to decompose accented characters, (2) strip diacritics, (3) convert to lowercase, (4) replace spaces and non-alphanumeric characters with the separator (usually a hyphen), (5) collapse consecutive separators, and (6) trim separators from the start and end.
Does this slug generator store my text?
No. All processing happens in your browser using JavaScript. Your text is never sent to any server. You can verify this by using the tool offline after the page loads.
What is the difference between a slug and kebab-case?
A slug and kebab-case are very similar — both use lowercase words separated by hyphens. The difference is context: 'slug' refers to the URL-friendly identifier for a web page, while 'kebab-case' is a general naming convention used in programming for variables, CSS classes, and file names. A slug is typically a kebab-case string derived from a title or name.