@sopkit/slug
v1.0.0
Published
Premium, lightweight URL slug generator and text clean-up utility with full Unicode/diacritics support.
Maintainers
Readme
@sopkit/slug
Premium, lightweight URL slug generator and text clean-up utility with full Unicode/diacritics support. Part of the SopKit utility ecosystem.
Online Interactive Tool
You can use the browser-based interactive version of this tool at SopKit Slug Generator.
Features
- Unicode normalization (decomposes accents and diacritics like
é➜e) - Custom separators (e.g.
-,_, or custom characters) - Case control (force lowercase/preserve case)
- Strict clean-up filters out special URL-breaking symbols
- Zero dependencies
- ESM and CommonJS support
Installation
npm install @sopkit/slugQuick Start
ESM
import { slugify, isValid } from "@sopkit/slug";
// Standard slugification
slugify("Hello World & Universe!"); // "hello-world-universe"
// Accent normalization
slugify("Café & résumé"); // "cafe-resume"
// Custom options
slugify("User Profile ID", { separator: "_", lowercase: false }); // "User_Profile_ID"
// Validation
isValid("hello-world"); // true
isValid("hello world!"); // falseCommonJS
const { slugify } = require("@sopkit/slug");
const slug = slugify("SopKit Slugify"); // "sopkit-slugify"License
MIT © SopKit
