stacks/ts-slug
publicClone
Push over the same URL. A password will not work: create a token under access tokens and use it in place of one.
- .config
- .github
- .vscode
- docs
- src
- test
- .editorconfig 147 B
- .gitattributes 12 B
- .gitignore 122 B
- buddy-bot.config.ts 855 B
- build.ts 133 B
- bun.lock 34.8 KB
- bunfig.toml 107 B
- CHANGELOG.md 10.9 KB
- clarity.config.ts 133 B
- CLAUDE.md 1.5 KB
- deps.yaml 32 B
- LICENSE.md 1.1 KB
- package.json 2.0 KB
- pkgx.yaml 31 B
- README.md 3.6 KB
- tsconfig.json 678 B

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-slugTesting
bun testChangelog
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:
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 💙
[codecov-href]: https://codecov.io/gh/stacksjs/ts-slug -->