sindresorhus/slugify
Slugify a string
Thành tựu nổi bật
Những danh hiệu mới nhất của dự án
#1 Repository Của Tuần
#1 Repository Của Tuần
#1 Repository Của Tuần
🚀 Slugify: Turn Any String into a URL‑Safe Slug
A tiny, dependency‑free library that handles Unicode, camelCase, and custom separators to create perfect slugs.
slugify by Sindre Sorhus is a zero‑dependency JavaScript function that transforms any input string into a URL‑friendly slug. It is useful for generating clean filenames, HTML IDs, or SEO‑friendly route segments. The library works in both Node.js and browsers, and it supports a wide range of languages through its underlying transliterate package.
✨ Highlights
- Unicode transliteration: Converts characters from German, Vietnamese, Arabic, Russian and many other scripts to ASCII.
- Decamelization: Splits
fooBarintofoo-barby default. - Custom replacements: Add your own mapping, e.g.,
['@', ' at '], applied before other transformations. - Flexible separator: Choose
-,_, or any string; default is-. - Case control: Lowercase output by default, or keep original case with
lowercase: false. - Preserve options: Keep leading underscores, trailing dashes, or specific characters like
#. - Locale support: Adjust transliteration for language‑specific rules via the
localeoption. - Counter helper:
slugifyWithCounter()generates unique slugs for repeated strings, with areset()method.
💡 Why it matters
Unlike many slugifiers that only handle ASCII, slugify leverages a robust transliteration engine, making it suitable for international content without extra configuration. Its small footprint and optional features let developers include only what they need, while the built‑in counter simplifies generating unique anchors in documentation or dynamic UIs.
#slugify #JavaScript #NodeJS #OpenSource #TiniX
Similar Projects
Discover other similar projects and AI models.
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.
cizgile — Zero-dependency URL slug engine. RFC 3986/3987 slugs, transliteration for 7 scripts, Unicode slugs, IRI ↔ URI, percent-encoding. Pure TypeScript, works everywhere.
Tiny, zero-dependency slug generator (~700 bytes gzipped) with full TypeScript support — converts strings into clean, RFC 3986-compliant slugs and reverts them back to sentences
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
Unicode to ASCII transliteration - C Elixir Go Java JS Julia PHP Python Ruby Rust Shell .NET