TS-Scribe - v0.6.2
    Preparing search index...

    Function slugifyString

    • Converts a string into a URL-friendly slug by removing accents, replacing spaces and special characters, and optionally converting to lowercase. Perfect for generating SEO-friendly URLs, filenames, and identifiers.

      Parameters

      • input: string

        The input string to slugify.

      • Optionaloptions: SlugifyOptions = {}

        Options to customize the slugification process.

      Returns string

      The slugified version of the input string.

      // Basic usage (strict mode by default)
      slugifyString("Hello World!")
      // Returns "Hello-World"
      // With lowercase and custom replacement
      slugifyString("Hello World! How are you?", { lowercase: true, replacement: "-" })
      // Returns "hello-world-how-are-you"
      // Remove accents and special characters
      slugifyString("Café Münchën", { lowercase: true })
      // Returns "cafe-munchen"
      // Custom replacement character
      slugifyString("TypeScript is Great", { replacement: "_", lowercase: true })
      // Returns "typescript_is_great"
      // Remove specific characters with custom regex
      slugifyString("Product #42 (New!)", { remove: /[#()!]/g, lowercase: true })
      // Returns "product-42-new"
      // Non-strict mode (only replaces spaces)
      slugifyString("Hello@World.com", { strict: false })
      // Returns "Hello@World.com"