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

sluggit

v1.3.0

Published

A utility for generating slugs from text strings in TypeScript.

Downloads

27

Readme

Sluggit

npm version downloads License: MIT

Sluggit is a lightweight TypeScript utility to convert strings into URL-friendly slugs. Removes emojis, accents, and special characters, supports custom separators, and preserves casing if needed.

This release refactors the codebase into small modules and introduces new options:

  • maxLength: limit the length of the generated slug while preserving word boundaries when possible
  • customReplacements: provide a mapping of characters/strings to replace before slugification
  • preserveNumbers: whether numbers should be kept in the slug (default: true)
  • removeTrailingDash: when true, removes any trailing separators from the final slug

Table of Contents

| Section | Description | | ------------------------------- | --------------------------------------- | | Features | Key functionality of the package | | Installation | How to install using NPM, Yarn, or PNPM | | Quick Start | Minimal example to start using Sluggit | | Usage | Full usage examples | | API Reference | Function signature and parameters | | Options | Available options and default values | | Examples | Example inputs and expected outputs |

Features

  • Convert any string to a URL-friendly slug
  • Remove special characters, emojis, and accents
  • Customizable separator (-, _, or any character)
  • Optional lowercase / uppercase
  • Supports ESM and CommonJS
  • TypeScript-ready with type definitions

Installation

# npm
npm install sluggit

# yarn
yarn add sluggit

# pnpm
pnpm add sluggit

Quick Start

import { sluggit } from "sluggit";

const slug = sluggit("Hello World!"); // Output: hello-world

Usage

import { sluggit } from "sluggit";

// Basic usage
sluggit("Hello World!"); // hello-world

// Custom separator
sluggit("Hello World!", { separator: "_" }); // hello_world

// Preserve case
sluggit("Hello World!", { lowercase: false }); // Hello-World

// Remove emojis
sluggit("Hello 👋 World! 🌍"); // hello-world

// Handle accents
sluggit("Hôtel Crémieux"); // hotel-cremieux

API Reference

Function Signature

function sluggit(input: string, options?: SluggitOptions): string;

Parameters

  • input (string): The string to convert to a slug
  • options (optional: SlugOptions): Configuration options

Return Value

  • Returns a string containing the URL-friendly slug

Options

The SlugOptions interface provides the following configuration options:

interface SluggitOptions {
  separator?: string; // Default: '-'
  lowercase?: boolean; // Default: true
  trim?: boolean; // Default: true
  maxLength?: number; // Optional: max length of the slug
  customReplacements?: Record<string, string>; // Optional mappings applied before slug generation
  preserveNumbers?: boolean; // Default: true
  removeTrailingDash?: boolean; // Default: false
}

Options Description

  • separator: Character to use between words (default: '-')

  • lowercase: Convert the output to lowercase (default: true)

  • trim: Remove leading and trailing separators (default: true)

  • maxLength: When provided, the function attempts to keep whole tokens, truncating only at token boundaries when possible. If a numeric tail (e.g., a year) is present and the token before it is included in the truncated result, the numeric tail will be appended.

  • customReplacements: A map of strings to replace prior to slug generation. Useful for mapping © → c, ™ → tm, & → and, etc.

  • preserveNumbers: Whether numbers should be preserved (default: true). Set to false to remove all digits.

  • removeTrailingDash: When true, strip trailing separators from the final slug.


Examples

Here are some example inputs and their corresponding outputs:

| Input | Options | Output | | ----------------------- | ---------------------------------------------- | ---------------------------- | | "Hello World!" | default | "hello-world" | | "Hello_World!" | { separator: '_' } | "hello_world" | | "Hello World!" | { lowercase: false } | "Hello-World" | | " Hello World! " | { trim: true } | "hello-world" | | "Café & Résumé" | { customReplacements: { "&": "and" }} | "cafe-and-resume" | | "Hello 👋 World! 🌍" | default | "hello-world" | | "Product™ & Copyright©" | { customReplacements: { "™": "tm", "©": "c" }} | "product-tm-and-copyright-c" |