Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/slug/mod.ts>slug

Deno library for converting arbitrary strings into valid slugs
Latest
function slug
import { slug } from "https://deno.land/x/slug@v1.1.0/mod.ts";

Converts a string into a valid slug

Examples

console.log(slug("some string")); // some-string console.log(slug("some string", "_")); // some_string console.log(slug("I ♥ UNICODE")); // I-love-UNICODE console.log(slug("I ♥ UNICODE"), { lower: true }); // i-love-unicode

slug("some ƒÚÑķÝ and ☢ string", { replacement: "-", remove: undefined, lower: true, strict: false, locale: "vi", trim: true, extends: { "☢": "nuclear" }, }); // some-fUNkY-and-nuclear-string

Parameters

input: string
optional
options: string | Partial<SlugOptions>

Returns

string