npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clean-slug-lite

v1.0.1

Published

Fast, zero-dependency, Unicode-aware URL slug generator for SEO, blogs, CMS, and clean URLs with symbol replacement and smart truncation.

Readme

🪶 clean-slug-lite

Fast, zero-dependency, Unicode-aware URL slug generator for SEO, blogs, CMS, and clean URLs with symbol replacement and smart word-boundary truncation.

npm version License: MIT Sponsor TypeScript


✨ Features

  • ⚡ Zero Dependencies — Ultra-lightweight (~1.5 KB), pure native regex & Unicode algorithms.
  • 🌍 Smart Accent Normalization — Automatically cleans diacritics (Café -> cafe, München -> munchen, español -> espanol).
  • 🔣 Intelligent Symbol Expansion — Expands & to and, @ to at, % to percent, and currencies ($, €, £, ₹).
  • ✂️ Word-Boundary Truncation — maxLength trims cleanly at whole words rather than slicing words in half.
  • 🌐 Unicode Preservation Option — Keep Cyrillic, Chinese, Arabic, or Devanagari scripts intact with preserveUnicode: true.
  • 🛠️ Custom Replacement Maps — Add tailored dictionary replacements (e.g. C# -> c-sharp).
  • 📦 Dual ESM & CommonJS — Works in Node.js, Next.js, Vite, React, Express, and browsers.

📥 Installation

npm install clean-slug-lite

or with Yarn / pnpm:

pnpm add clean-slug-lite
# or
yarn add clean-slug-lite

🚀 Quick Start

1. Basic Slug Generation

import { slugify } from 'clean-slug-lite';

console.log(slugify('Hello World!'));
// "hello-world"

console.log(slugify('Rock & Roll @ 100%'));
// "rock-and-roll-at-100-percent"

2. Accents & Diacritics Normalization

import { slugify } from 'clean-slug-lite';

console.log(slugify('Café au Lait'));
// "cafe-au-lait"

console.log(slugify('München Oktoberfest'));
// "munchen-oktoberfest"

console.log(slugify('¿Cómo estás?'));
// "como-estas"

3. Word-Boundary Truncation (maxLength)

Ensures words aren't abruptly cut into unreadable fragments:

import { slugify } from 'clean-slug-lite';

const title = 'The quick brown fox jumps over the lazy dog';

// Cleanly cuts at the nearest word boundary:
console.log(slugify(title, { maxLength: 25 }));
// "the-quick-brown-fox-jumps"

4. Custom Word Replacements

import { slugify } from 'clean-slug-lite';

const slug = slugify('Full-stack guide to C# and .NET', {
  customReplacements: {
    'C#': 'c-sharp',
    '.NET': 'dotnet',
  },
});

console.log(slug);
// "full-stack-guide-to-c-sharp-and-dotnet"

5. Validate Slugs (isValidSlug)

import { isValidSlug } from 'clean-slug-lite';

console.log(isValidSlug('valid-clean-slug-123')); // true
console.log(isValidSlug('Invalid Slug!')); // false

⚙️ Options Reference

slugify(text, options)

| Option | Type | Default | Description | |---|---|---|---| | separator | string | '-' | Word separator character (e.g. '-' or '_'). | | lower | boolean | true | Convert result to lower case. | | trim | boolean | true | Strip leading and trailing separators. | | maxLength | number | undefined | Truncate length at word boundary. | | preserveUnicode | boolean | false | Preserve non-Latin scripts (Cyrillic, Devanagari, etc.). | | replaceSymbols | boolean | true | Expands symbols like &, @, %, +, currencies. | | customReplacements | Record<string, string> | undefined | Key-value pairs of terms to replace before slugification. |


🛠 Development & Testing

# Install dependencies
npm install

# Run unit tests
npm test

# Build dual ESM/CJS bundles + .d.ts types
npm run build

💖 Support the Project

If you find this package useful, consider sponsoring its ongoing development and maintenance: 👉 Sponsor @Piratha97 on GitHub Sponsors

📄 License

MIT © 2026 Pirapaakaran Pirathapan