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.
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
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'
# npm
npm install ts-slug
# yarn
yarn add ts-slug
# pnpm
pnpm add ts-slug
# bun
bun install ts-slug
bun test
Please see our releases page for more information on what has changed recently.
Please see CONTRIBUTING for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using this package:
Join the Stacks Discord Server
"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 🌎
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.
The MIT License (MIT). Please see LICENSE for more information.
Made with 💙