RepositoryJavaScript
sindresorhus

sindresorhus/slugify

Slugify a string

2.7ksao
108fork
1issue
2lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: slug

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: slugify

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: transliteration

#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 fooBar into foo-bar by 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 locale option.
  • Counter helper: slugifyWithCounter() generates unique slugs for repeated strings, with a reset() 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

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryPHP
ausi/slug-generator

Slug Generator Library for PHP, based on Unicode’s CLDR data

799
Sep 8, 2023
RepositoryPHP
jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

673
Apr 3, 2025
RepositoryTypeScript
productdevbook/cizgile

cizgile — Zero-dependency URL slug engine. RFC 3986/3987 slugs, transliteration for 7 scripts, Unicode slugs, IRI ↔ URI, percent-encoding. Pure TypeScript, works everywhere.

122
Oct 20, 2026
RepositoryTypeScript
stldo/url-slug

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

93
Sep 20, 2026
RepositoryTypeScript
freeCodeCamp/freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

459.4k
Nov 20, 2026
RepositoryJavaScript
pid/speakingurl

Generate a slug – transliteration with a lot of options

1.1k
Mar 15, 2024
RepositoryJavaScript
vercel/next.js

The React Framework

143.6k
Nov 23, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.6k
Nov 23, 2026
RepositoryKotlin
anyascii/anyascii

Unicode to ASCII transliteration - C Elixir Go Java JS Julia PHP Python Ruby Rust Shell .NET

428
Jun 6, 2026