https://github.com/danieldietrich/slugify
Turns strings into user-friendly and search engine-friendly URL slugs.
https://github.com/danieldietrich/slugify
ascii latin-1 roman slug slugify typescript unicode uri url
Last synced: about 1 month ago
JSON representation
Turns strings into user-friendly and search engine-friendly URL slugs.
- Host: GitHub
- URL: https://github.com/danieldietrich/slugify
- Owner: danieldietrich
- License: mit
- Created: 2019-08-31T06:12:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:59:02.000Z (over 2 years ago)
- Last Synced: 2025-03-01T03:26:40.535Z (about 2 months ago)
- Topics: ascii, latin-1, roman, slug, slugify, typescript, unicode, uri, url
- Language: TypeScript
- Homepage:
- Size: 576 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/@danieldietrich/slugify/)[](https://snyk.io/test/npm/@danieldietrich/slugify)[](https://bundlephobia.com/result?p=@danieldietrich/slugify@latest)
[](https://travis-ci.org/danieldietrich/slugify/)[](https://codecov.io/gh/danieldietrich/slugify/)

[](https://github.com/sponsors/danieldietrich)[](https://paypal.me/danieldietrich13)[](https://opensource.org/licenses/MIT/)
[](https://twitter.com/danieldietrich/)# slugify
Turns strings into user-friendly and search engine-friendly [URL slugs](https://en.wikipedia.org/wiki/Clean_URL#Slug).
Slugify uses a [dictionary](https://github.com/danieldietrich/slugify/wiki/Dictionary) to translate certain glyphs to the alphabet `a-z A-Z 0-9`. Beside whitespace, the characters `!#$%&()*+,-./:;=?@[\]_|~` are considered as space. All other characters are removed, especially single `'` and double `"` quotes. Finally, the words are joined, by default with hyphen '-'.
A highlight of this solution is the readability of slugs. Only words and a single separator type are used.
## Installation
```bash
npm i @danieldietrich/slugify
```## Usage
The module supports ES6 _import_ and CommonJS _require_ style.
```ts
import slugify from '@danieldietrich/slugify';// I-love-it
slugify('I ♥ it!');// I_love_it
slugify('I ♥ it!', '_');// cafebab3-gmail-com
slugify('[email protected]');// dos-and-donts
slugify("Do's and Don'ts").toLowerCase();
```---
Copyright © 2020 by [Daniel Dietrich]([email protected]). Released under the [MIT](https://opensource.org/licenses/MIT/) license.