🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ts-slug

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-slug

Generate slugs from strings. Browser & Bun/Node.js compatible.

0.1.0
latest
Source
npm
Version published
Weekly downloads
797
56.58%
Maintainers
1
Weekly downloads
 
Created
Source

Social Card of this repo

npm version GitHub Actions Commitizen friendly

ts-slug

A powerful TypeScript library for converting text strings into URL-friendly slugs. Whether you're building a blog, CMS, or any application that needs clean, normalized URLs, ts-slug provides a robust solution with excellent multilingual support.

Features

ts-slug offers a range of powerful features:

  • 🌍 Unicode Support - Handles special characters from any language
  • 🔤 Locale-specific Handling - Special support for German, Bulgarian, Serbian, Ukrainian, and more
  • ⚙️ Highly Configurable - Customize replacement characters, case sensitivity, and more
  • 🔄 Multiple Modes - Choose between RFC 3986 compliant or pretty URL formats
  • 📝 TypeScript Native - Full type definitions included
  • 🪶 Zero Dependencies - Lightweight with no external dependencies
  • 🧪 Thoroughly Tested - Comprehensive test suite ensures reliability

Quick Example

import slug from 'ts-slug'
// alternatively
// import { slug } from 'ts-slug'

// Basic usage
slug('Hello World') // 'hello-world'

// With options
slug('Hello World', {
  replacement: '_',
  lower: false
}) // 'Hello_World'

// Multilingual support
slug('こんにちは世界') // 'konnichihasei-jie'
slug('Schöne Grüße', { locale: 'de' }) // 'schoene-gruesse'

Installation

# npm
npm install ts-slug

# yarn
yarn add ts-slug

# pnpm
pnpm add ts-slug

# bun
bun install ts-slug

Testing

bun test

Changelog

Please see our releases page for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

Postcardware

"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.

Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎

Credits

Sponsors

We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.

License

The MIT License (MIT). Please see LICENSE for more information.

Made with 💙

Keywords

typescript

FAQs

Package last updated on 13 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts