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 🙏

© 2025 – Pkg Stats / Ryan Hefner

doslug

v0.0.3

Published

A lightweight utility for converting strings into URL-friendly slugs with CLI and API support

Readme

DoSlug

NPM version

A lightweight utility for converting strings into URL-friendly slugs, with CLI and API support.

DoSlug is a simple Node.js tool that transforms strings into clean, URL-friendly slugs by removing accents, converting to lowercase, replacing spaces with hyphens, and more. It supports both programmatic usage via an API and a command-line interface for quick slug generation.


Features ✨

  • 🔹 Simple API: Convert strings to slugs with a single function call.
  • 🚀 CLI Ready: Generate slugs directly from the terminal with a single command.
  • 🌐 Cross-Platform: Works in modern Node.js environments with TypeScript support.
  • Fast & Minimal: Lightweight with no external dependencies and robust error handling.
  • 🔄 Robust Slugification: Handles accents, diacritics, special characters, and multiple spaces or hyphens.

Installation 💿

# Using npm
npm install doslug

# Using pnpm
pnpm add doslug

# Using yarn
yarn add doslug

Usage 📦

API </>

The doslug module provides a single function, doslug, to convert strings into URL-friendly slugs. Below is the API with JSDoc documentation.

import { doSlug } from 'doslug';

// Convert a string to a slug
console.log(doSlug('Héllo Wörld!!!')); // 'hello-world'

// Handle special characters and spaces
console.log(doSlug('  Café & Croissants  ')); // 'cafe-croissants'

// Empty string returns default slug
console.log(doSlug('')); // 'default-slug'

// Multiple hyphens and special characters
console.log(doSlug('Hello---World!!!')); // 'hello-world'

API Details

  • doSlug(str: string): string
    • Input: A string to be converted into a slug.
    • Output: A URL-friendly slug (lowercase, no accents, spaces replaced with hyphens, special characters removed).
    • Throws: An error if the input is not a string.
    • Default: Returns 'default-slug' if the result would be an empty string.

CLI 🖥️

#!/usr/bin/env node
doslug [string] [options]

Example Commands

# Convert a string to a slug
doslug "Héllo Wörld!!!"
# Output: hello-world

# Handle empty string
doslug ""
# Output: default-slug

# Show version
doslug --version
# Output: doslug v1.0.0

# Show help
doslug --help
# Output: (see help message below)

CLI Options

  [string]                 Convert the provided string to a URL-friendly slug
  --help                   Show this help message
  --version                Show version

CLI Help Output

Running doslug --help displays:

Usage: doslug [string] [options]

Commands:
  [string]                 Convert the provided string to a URL-friendly slug
  --help                   Show this help message
  --version                Show version

Examples:
  doslug "Héllo Wörld!!!"
  doslug --version
  doslug --help

CLI Usage Example

Install doslug globally to use it from the command line:

npm install -g doslug

Then run:

doslug "My Awesome Post!!!"
# Output: my-awesome-post

doslug "Café au Lait"
# Output: cafe-au-lait

doslug --version
# Output: doslug v1.0.0

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R (estarlincito.com)