URL Slug Generator
Last updated: 27 June 2026
Reviewed by Gavin Meiring, Lead research and primary author · Doctoral Candidate (Corporate Governance) · Research and drafting assisted by AI
Example inputs
- URL slugs were popularised by blogging platforms like WordPress in the early 2000s. Before that, URLs were typically system-generated IDs like '?p=123'.
- Google treats hyphens in URLs as word separators but treats underscores as connecting characters. 'word-count' is read as two words. 'word_count' is read as one.
- Short, descriptive slugs consistently outperform long ones in search rankings. Studies suggest URLs under 60 characters perform significantly better in click-through rates.
Slug Generator
A slug generator converts a page title or heading into a URL-friendly string by removing special characters, replacing spaces with hyphens, and lowercasing all letters. It is an essential tool for web developers, content managers, and bloggers who need clean, readable URLs for their pages and posts.
How to Use the Slug Generator
- Type or paste your title or phrase into the input field.
- Click the generate button.
- The tool outputs a lowercase, hyphenated version of your text with all special characters removed.
- Copy the slug and use it in your CMS, routing configuration, or URL structure.
- Review the result to ensure it accurately represents the page content.
The Formula
A slug generator applies a sequence of text conversions:
- Convert all characters to lowercase.
- Replace accented characters with their plain ASCII equivalents (for example, "é" becomes "e").
- Remove all characters that are not letters, numbers, or spaces.
- Replace one or more consecutive spaces (or hyphens) with a single hyphen.
- Strip any leading or trailing hyphens from the result.
For example, "10 Best Cafés in London!" becomes "10-best-cafes-in-london". This format is compatible with all major web servers and browsers, and avoids URL encoding issues that arise from spaces and special characters.
Real-World Example
You are writing a blog post titled "How to Calculate Your PAYE Tax (2026 Guide)". You need a URL slug for your CMS.
- Lowercase: "how to calculate your paye tax (2026 guide)"
- Remove parentheses and special characters: "how to calculate your paye tax 2026 guide"
- Replace spaces with hyphens: "how-to-calculate-your-paye-tax-2026-guide"
The resulting URL becomes yourblog.com/how-to-calculate-your-paye-tax-2026-guide, which is clean, descriptive, and search-engine friendly.
Why Slugs Matter for SEO
Search engines use URL structure as a ranking signal. A descriptive slug that contains your primary keyword communicates page content to both crawlers and users. Avoid slugs that contain stop words unnecessarily (such as "a", "the", "and") or that use query parameters (like ?id=1234). Keep slugs concise: aim for 3 to 5 meaningful words rather than reproducing the entire title. Once published, avoid changing slugs, as this breaks inbound links and loses accumulated page authority unless you set up a permanent redirect.
Frequently Asked Questions
Should I include stop words like "the" and "and" in my slug? Generally, no. Removing stop words produces shorter, cleaner URLs. However, if removing them makes the slug ambiguous or hard to read, keeping one or two key connective words is acceptable.
What is the maximum recommended slug length? Most SEO practitioners recommend keeping slugs under 60 characters. Very long slugs are truncated in search results and may dilute keyword relevance by including too many terms.
Can I use underscores instead of hyphens? Hyphens are strongly preferred. Google treats hyphens as word separators but treats underscores as word joiners, meaning "word_count" is read as a single token rather than two separate words. Always use hyphens.
Does the slug need to match the page title exactly? No. A good slug distils the title to its core keywords. "The Ultimate Guide to Baking Perfect Sourdough Bread at Home" might become "sourdough-bread-guide", which is shorter and still clearly describes the page.
Worked example: stripping a German title down to a slug
The title "München: 10 Beste Cafés (2026)" exercises every step in the conversion. It runs 30 characters and 32 bytes, because the u with an umlaut (U+00FC) and the e with an acute accent (U+00E9) each take two bytes in UTF-8.
The five steps in the formula section produce a 27-character slug.
- Lowercase gives "münchen: 10 beste cafés (2026)".
- Normalise to NFKD. This splits each accented letter into a base letter plus a separate combining mark.
- Drop the combining marks, which leaves "munchen: 10 beste cafes (2026)".
- Replace every run of separators with a single hyphen, which gives "-munchen-10-beste-cafes-2026".
- Trim the leading and trailing hyphens. The slug is munchen-10-beste-cafes-2026.
The three characters that disappear are the colon and the two brackets. The three spaces become three hyphens, so the slug keeps a word break where the title had one. Every remaining character sits inside the unreserved set, which means the slug travels through a URL unchanged.
This table runs six titles through the same five steps.
| Title | Title characters | Title bytes | Slug | Slug characters |
|---|---|---|---|---|
| How to Calculate Your PAYE Tax (2026 Guide) | 43 | 43 | how-to-calculate-your-paye-tax-2026-guide | 41 |
| 10 Best Cafés in London! | 24 | 25 | 10-best-cafes-in-london | 23 |
| München: 10 Beste Cafés (2026) | 30 | 32 | munchen-10-beste-cafes-2026 | 27 |
| C++ vs Java: Which Is Faster? | 29 | 29 | c-vs-java-which-is-faster | 25 |
| The Ultimate Guide to Sourdough (Updated 2026) | 46 | 46 | the-ultimate-guide-to-sourdough-updated-2026 | 44 |
| 50% Off: Winter Sale!!! | 23 | 23 | 50-off-winter-sale | 18 |
A reader can check any row by hand. The sourdough row is the interesting one: it loses only two characters, because the title is already plain ASCII and the brackets are the only punctuation. The C++ row loses four, and the word "C" survives on its own because the plus signs are dropped rather than spelled out.
The character set a slug is allowed to use
RFC 3986 is the IETF standard for URI syntax. Section 2.3 defines the unreserved characters as the 52 Latin letters, the 10 digits, and four marks: hyphen, full stop, underscore and tilde. That is 66 characters in total. A slug built only from those characters needs no encoding anywhere in a URL path.
Everything else must be percent-encoded, or removed before the slug is built. A space becomes %20. A Latin letter with an accent becomes two escapes, one per byte. A character outside the Basic Latin range can take three escapes on its own.
The hyphen is the conventional separator because search engines read it as a break between words. The other joining character in the set carries no such meaning, and search engines have treated it as a word joiner instead, so a URL ending in word_count has read as a single token for as long as webmasters have been arguing about it.
Length in characters, bytes and percent-encoded form
The three measures come apart as soon as non-ASCII characters enter the title.
| Text | Characters | UTF-8 bytes | Percent-encoded | Encoded characters |
|---|---|---|---|---|
| café | 4 | 5 | caf%C3%A9 | 9 |
| Düsseldorf | 10 | 11 | D%C3%BCsseldorf | 15 |
| Zürich | 6 | 7 | Z%C3%BCrich | 11 |
| naïve | 5 | 6 | na%C3%AFve | 10 |
| Ångström | 8 | 10 | %C3%85ngstr%C3%B6m | 18 |
| 東京 | 2 | 6 | %E6%9D%B1%E4%BA%AC | 18 |
A slug generator that strips accents avoids the encoded column entirely. Zürich becomes zurich, six characters, and the URL stays short. A page that keeps the accented letter and lets the browser encode it produces an 11-character path segment for the same word. Tokyo written in Japanese characters costs 18 characters either way, because NFKD does not decompose those characters into Latin forms. Scripts outside Latin need a transliteration table, not a diacritic strip.
When transliteration beats accent stripping
Stripping a diacritic keeps the base letter, which suits languages where the mark shows stress or vowel quality that an English reader can lose without confusion. German marks a different problem. The convention for writing German without umlauts is ae, oe and ue, and the sharp s becomes ss. A reader searching for Duesseldorf types that spelling, and a slug reading dusseldorf is a different string.
The word Straße shows the failure. It is 6 characters and 7 bytes. Stripping diacritics changes nothing, because NFKD does not decompose the sharp s. The next step removes it as a non-letter, and the result is strae, which no German reader recognises as a word. Transliteration gives strasse, which every German reader recognises at a glance.
A Greek or Cyrillic name needs a mapping table for the whole script. That is a larger job than slug generation, and a tool that claims to handle it should name the transliteration scheme it uses, because the schemes disagree with each other.
What a slug change costs after publication
A published slug is an address. Changing it breaks every inbound link, every bookmark and every share that used the old one. The mechanic behind the advice to leave published slugs alone is worth spelling out. A permanent redirect passes the accumulated signals to the new address, but a search engine reprocesses that redirect on its own schedule, and third-party links keep pointing at the old address for years.
Two habits keep the cost down. Add the redirect on the same day the slug changes, and keep a list of retired slugs so the redirects survive a later platform migration. Fix a wrong slug early. A page two days old with no inbound links costs nothing to rename. A page two years old with 200 referring domains carries a redirect that must never be removed, because removing it turns every one of those links into a dead end.
Where the 60-character budget comes from
A search result truncates the display of a long URL, and a truncated URL hides the words at the end, which are often the ones that identify the page. The budget of about 60 characters is a working rule rather than a standard, and it applies to the slug, not to the whole address. A content management system usually adds a path in front of the slug. On a blog that serves its posts from /blog/2026/, a 41-character slug becomes a 52-character path segment before the domain is counted.
The hard ceiling is far above that. The widely cited limit of 2,083 characters for older versions of Internet Explorer is a browser artefact rather than a web standard, and no current browser enforces it. Length matters for display and for readability, not for correctness. A slug of 300 characters still resolves. A slug of 60 characters still displays in full.
Also try these free tools: