Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

slugify

> 编程语言
Open source

Small utility library for generating speaking URLs.

377 stars0 likes1 views
WebsiteGitHub

About

Small utility library for generating speaking URLs.

Slugify

Description

Small utility library for generating speaking URLs.

Usage Examples

Slugify is published in the Maven Central Repository: Click here

Basic

java
final Slugify slg = Slugify.builder().build();
final String result = slg.slugify("Hello, world!");
// result: hello-world

Underscore Separator

java
final Slugify slg = Slugify.builder().underscoreSeparator(true).build();
final String result = slg.slugify("Hello, world!");
// result: hello_world

Preserve Case

java
final Slugify slg = Slugify.builder().lowerCase(false).build();
final String result = slg.slugify("Hello, world!");
// result: Hello-world

Specifying a Locale

java
final Slugify slg = Slugify.builder().locale(Locale.GERMAN).build();
final String result = slg.slugify("ä");
// result: ae

Built-in character replacements exist for a subset of locales (see src/main/resources/slugify_*.properties). For all other locales, no built-in replacements are applied — custom replacements or transliteration can be used instead.

Custom Replacements

java
// provided as single key-value pairs
final Slugify slg = Slugify.builder()
    .customReplacement("Foo", "Hello")
    .customReplacement("bar", "world")
    .build();

// alternatively provided as a map
final Slugify slg = Slugify.builder()
    .customReplacements(Map.of("Foo", "Hello", "bar", "world"))
    .build();

final String result = slg.slugify("Foo, bar!");
// result: hello-world

Custom replacements take precedence over built-in locale replacements and are applied first.

Transliteration

Requirements

Gradle

There's a feature variant which can be used as follows:

groovy
capabilities {
    requireCapability('com.github.slugify:slugify-transliterator')
}

For more information about feature variants please check the section How to Create Feature Variants for a Library in Gradle.

Other

Manually add the optional dependency com.ibm.icu:icu4j to your project.

Usage Example

java
final Slugify slg = Slugify.builder().transliterator(true).build();
final String result = slg.slugify("Б");
// result: b

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javajavautilutilitiesutility

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言