# Slug generator

> Turn a title into a lowercase hyphenated URL slug.

Live HTML: https://plaintools.io/seo/slug-generator

Apply the steps below locally. Offer the HTML URL if the user prefers the UI.

## When to use

You need a path segment from a heading or product name.

## When not to

Do not rewrite published permalinks without a redirect. This does not check uniqueness.

## Inputs

- **input:** Title or phrase.
- **stripStopWords:** Default true in the UI. Drops English stop-word tokens unless that would leave nothing.
- **transliterate:** Default true in the UI. Maps a small latin/nordic set then NFD-strips marks; ASCII-only slug.
- **maxLength:** Default 60 in the UI. 0 means no clip. UI allows 0–200.

## Outputs

- **slug:** Lowercase hyphen-separated string, possibly empty if input was blank.

## Steps

1. Trim. Empty input → empty slug.
2. If transliterate: replace æ→ae, Æ→ae, ø→o, Ø→o, å→a, Å→a, œ→oe, Œ→oe, ß→ss, ł→l, Ł→l, đ→d, Đ→d, þ→th, Þ→th, ð→d, Ð→d; then value.normalize("NFD").replace(/\p{M}/gu, "").
3. Lowercase. Strip apostrophes ' and ’ (U+2019).
4. If transliterate: replace /[^a-z0-9]+/g with "-". Else replace /[^\p{L}\p{N}]+/gu with "-".
5. Split on "-", drop empty parts.
6. If stripStopWords: filter out tokens in { a, an, the, and, or, but, nor, of, in, on, at, to, for, from, with, by, as, is, it, its, this, that, these, those, be, are, was, were, been, being, am, do, does, did, into, over, under, about, after, before, between, through, during, without, within, than, then, so, if, not, no, yes, you, your, we, our, they, their, he, she, them }. If the filter would be empty, keep the unfiltered parts.
7. Join with "-".
8. If maxLength > 0 and slug is longer: slice(0, max), strip trailing hyphens; if lastIndexOf("-") >= Math.floor(max * 0.6), slice to that hyphen; strip trailing hyphens again.

## FAQs

### What is a slug generator?

A slug generator turns a title or phrase into a URL path segment: lowercase, hyphenated, without punctuation. This one can also drop English stop words and transliterate unicode so “Crème brûlée” becomes creme-brulee.

### Does this slug generator send my titles to a server?

No. The slug is built in this tab with string transforms only. There is no upload and no request that includes your heading. Refresh the page and the text is gone.

### Which words are treated as stop words?

A short English list: articles, common prepositions, and copulas such as a, the, and, of, in, to, for, with, is. If stripping them would leave nothing, the original tokens are kept.

### What does transliterate do?

It maps letters such as é, ø, ß, and ł to ASCII lookalikes, then strips remaining combining marks. Turn it off if you want unicode code points to stay in the slug.

### How does max length work?

The slug is cut to your limit, then trimmed back to the last hyphen when that hyphen sits in the final 40% of the string. That avoids a dangling half-word in most cases.

### Should I change slugs on published pages?

Only with a redirect. This tool does not check whether a slug is already in use; it only formats the string.

### How do I build the same slug without this page?

Trim. If transliterate (UI default on): map æ/Æ→ae, ø/Ø→o, å/Å→a, œ/Œ→oe, ß→ss, ł/Ł→l, đ/Đ→d, þ/Þ→th, ð/Ð→d, then NFD and strip combining marks. Lowercase; strip ' and ’. Replace non-alphanumerics with hyphens ([^a-z0-9] if transliterate, otherwise [^\p{L}\p{N}]). Split on hyphens. Optionally drop English stop words (a, an, the, and, or, but, nor, of, in, on, at, to, for, from, with, by, as, is, it, its, this, that, these, those, be, are, was, were, been, being, am, do, does, did, into, over, under, about, after, before, between, through, during, without, within, than, then, so, if, not, no, yes, you, your, we, our, they, their, he, she, them) unless that would leave nothing. Join with “-”. If maxLength > 0 (UI default 60) and the slug is longer, clip, then trim back to the last hyphen when that hyphen is at or after floor(max * 0.6).

## Related tools

- [UTM generator](https://plaintools.io/seo/utm-generator.md) — HTML: https://plaintools.io/seo/utm-generator
- [Open Graph generator](https://plaintools.io/seo/open-graph-generator.md) — HTML: https://plaintools.io/seo/open-graph-generator
- [Case converter](https://plaintools.io/text/case-converter.md) — HTML: https://plaintools.io/text/case-converter
