Skip to content
Toolcroft

Text Tools

Slug Generator - Convert Text to URL Slug

Convert any text to a clean URL slug. Choose your separator (hyphen, underscore, dot), set a max length, and transliterate accented characters. Free, runs in your browser.

Your slug will appear here…

What makes a good URL slug?

A well-formed URL slug is short, descriptive, and contains only lowercase letters, numbers, and hyphens. It should reflect the content of the page. Search engines use the slug as a relevance signal, and users see it in the browser address bar and in shared links.

  • Use hyphens, not underscores (Google treats hyphens as word separators).
  • Keep it under 75 characters when possible; long slugs get truncated in SERPs.
  • Remove stop words ("a", "the", "and") unless they are meaningful.
  • Avoid special characters, accents, and non-ASCII characters without transliteration.

Transliteration: handling accented characters

Accented characters like é, ñ, ü, and ç are technically valid in URLs (they are percent-encoded by browsers) but they create ugly, hard-to-share links. Transliteration converts them to their closest ASCII equivalent: "café" -> "cafe", "jalapeño" -> "jalapeno", "straße" -> "strasse". Enable transliteration (it is on by default) to produce clean, universally shareable slugs.

Separator choice

For public-facing URLs (blog posts, product pages, landing pages), use a hyphen (-). Underscores (_) are common in file systems and Python package names. Dots (.) are occasionally used in versioned documentation paths. All three options produce valid URLs.

Max length

Many content management systems impose a slug length limit. WordPress defaults to 200 characters; Shopify trims at 255. For SEO best practice, keep slugs under 75 characters. Enable the max length option to truncate automatically. The tool never cuts in the middle of a word.

CMS behavior differences

PlatformMax slug lengthAuto-generation
WordPress200 charactersGenerated from post title on save
Shopify255 charactersGenerated from product title; editable
Next.jsNo built-in limitManual - developer defines slug generation logic
Ghost CMS191 charactersGenerated from post title; editable
Contentful256 charactersNo auto-generation; set manually

Dynamic slug generation (JavaScript)

To generate slugs programmatically in JavaScript or TypeScript:

const slugify = (text) =>
  text.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');

For production use with accented characters, consider the slugify npm package or a Unicode-aware transliteration library.

Unique slug strategies

When a slug already exists (e.g., a second blog post titled "My Vacation"), avoid collisions with one of these strategies:

  • Auto-increment suffix: append -2, -3, etc. (e.g., WordPress behavior). Simple and predictable.
  • UUID fragment: append the first 8 characters of a UUID (e.g., my-vacation-a3f2c1b4). Guaranteed unique but less readable.
  • Date prefix: prepend the publish date (2025-06-my-vacation). Works well for news sites where articles share titles on different dates.