@lacspace/slugify
v1.0.3
Published
Turn any text into a clean, SEO-friendly URL slug — transliterates diacritics, collapses separators, and guarantees uniqueness against an existing set. Zero-dependency, isomorphic.
Maintainers
Readme
@lacspace/slugify
Turn any text into a clean, SEO-friendly URL slug.
Transliterates common diacritics (
é → e), strips the rest, collapses separators, truncates on word boundaries, and can guarantee uniqueness against existing slugs. Perfect for article/product URLs.
- ✂️
slugify()withlower/separator/maxLength/ customreplace - 🔢
uniqueSlug()— appends-2,-3… against aSet/array - ⚡ Zero dependencies · 🌍 isomorphic · 📦 ESM + CJS · fully typed
Install
npm install @lacspace/slugify # or pnpm add / yarn add / bun addUsage
import { slugify, uniqueSlug } from "@lacspace/slugify";
slugify("Héllo, World! — 2026"); // "hello-world-2026"
slugify("StockYatra: Paper Trading"); // "stockyatra-paper-trading"
slugify("Über Café", { separator: "_" }); // "uber_cafe"
slugify("A very long article title here", { maxLength: 15 }); // "a-very-long" (word boundary)
uniqueSlug("Hello", new Set(["hello", "hello-2"])); // "hello-3"Custom replacements
slugify("C++ & C#", { replace: { "++": "pp", "#": "sharp" } }); // "cpp-csharp"The Lacspace SEO Kit
| Package | For |
| --- | --- |
| @lacspace/seo | Metadata & JSON-LD |
| @lacspace/sitemap | sitemap.xml |
| @lacspace/robots | robots.txt |
| @lacspace/llms-txt | llms.txt / llms-full.txt |
| @lacspace/site-verify | Search-engine verification |
| @lacspace/rss | RSS / Atom / JSON feeds |
| @lacspace/slugify | SEO URL slugs (this package) |
Licensing
This package is free under the Lacspace Free Licence — MIT-equivalent freedoms. Use it in personal and commercial projects at no cost; just keep the notice.
Not every Lacspace package is free. We also offer Commercial (paid), Client-specific, and Private (proprietary) packages under separate terms. See the full Lacspace Licence Centre.
Part of the Lacspace ecosystem — 35 zero-dependency, isomorphic TypeScript packages.
