URL Slug Generator
Convert any title or text to a clean, URL-safe slug. Choose separator, case, and whether to strip stop words.
About the URL Slug Generator
A URL slug is the human-readable, URL-safe part of a web address that identifies a specific page. Good slugs are lowercase, hyphen-separated, and free of special characters. They improve both SEO and user experience: search engines use words in URLs as a relevance signal, and descriptive slugs help users understand where a link leads before clicking.
Rules for a good URL slug
- Lowercase only — /My-Page and /my-page are treated as different URLs, causing duplicate content issues. Use lowercase throughout.
- Hyphens, not underscores — Google treats hyphens as word separators but underscores as joining characters.
my-pageis two words;my_pageis one compound term. - Remove stop words — "a", "the", "and", "of" can usually be removed without losing meaning, keeping slugs shorter.
- Keep it short — 3-5 meaningful words is ideal. Long slugs are harder to share and may be truncated in search results.
Changing slugs after publication
Once a URL is indexed and linked to, changing the slug without a 301 redirect breaks incoming links and loses accumulated PageRank. If you must change a slug, always configure a permanent redirect from the old URL to the new one. Most CMS platforms do this automatically when you update a post slug.
Slug generation in popular frameworks
Most web frameworks provide built-in slug generation. Rails has parameterize. Django has slugify. WordPress generates slugs automatically from post titles. In JavaScript, the simplest approach is: convert to lowercase, replace spaces with hyphens, and remove characters that are not alphanumeric or hyphens.
- JavaScript —
str.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"") - Python —
import re; re.sub(r"[^a-z0-9-]","",s.lower().replace(" ","-")) - Ruby on Rails —
"My Title".parameterizereturns "my-title" - WordPress — uses
sanitize_title()which handles Unicode, stop words, and special characters
Frequently Asked Questions
Redirect 301 /old-slug /new-slug. Nginx: return 301 /new-slug; inside a location block. WordPress: update the post slug and it creates the redirect automatically. Always use 301 (permanent) not 302 (temporary) to pass SEO value to the new URL.