Socket
Socket
Sign inDemoInstall

@sindresorhus/slugify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sindresorhus/slugify

Slugify a string


Version published
Weekly downloads
921K
increased by1.8%
Maintainers
1
Weekly downloads
 
Created

What is @sindresorhus/slugify?

@sindresorhus/slugify is a simple and efficient npm package used to convert strings into URL-friendly slugs. It handles various edge cases, such as special characters, spaces, and diacritics, making it a reliable choice for generating slugs from user input or other text data.

What are @sindresorhus/slugify's main functionalities?

Basic Slugification

This feature converts a basic string into a URL-friendly slug by replacing spaces with hyphens and converting the text to lowercase.

const slugify = require('@sindresorhus/slugify');
const slug = slugify('Hello World!');
console.log(slug); // 'hello-world'

Custom Replacement Characters

This feature allows you to customize the separator character used in the slug, such as using an underscore instead of a hyphen.

const slugify = require('@sindresorhus/slugify');
const slug = slugify('Hello World!', { separator: '_' });
console.log(slug); // 'hello_world'

Handling Diacritics

This feature removes diacritics from characters, ensuring that the resulting slug is composed of standard ASCII characters.

const slugify = require('@sindresorhus/slugify');
const slug = slugify('Crème brûlée');
console.log(slug); // 'creme-brulee'

Custom Replacement Map

This feature allows you to define custom replacements for specific characters or strings, providing greater control over the slugification process.

const slugify = require('@sindresorhus/slugify');
const slug = slugify('foo@bar', { customReplacements: [['@', 'at']] });
console.log(slug); // 'foo-at-bar'

Other packages similar to @sindresorhus/slugify

Keywords

FAQs

Package last updated on 05 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc