Slugifies a string
Latest commit da072f8 Jan 8, 2017 @simov 1.1.0
Failed to load latest commit information.
test Explain about the module instance Jan 1, 2017
.editorconfig Fix indentation to 2 spaces Mar 3, 2015
.eslintrc Update .eslintrc Dec 30, 2016
.gitignore Refactor Aug 8, 2016
.travis.yml Refactor Aug 8, 2016
LICENSE Refactor Aug 8, 2016 Update docs Jan 8, 2017
index.js Ignore browser and amd loader test coverage Dec 30, 2016
package.json 1.1.0 Jan 8, 2017


npm-version travis-ci coveralls-status

var slugify = require('slugify')

slugify('some string') // some-string

// if you prefer something other than '-' as separator
slugify('some string', '_')  // some_string
  • Vanilla ES5 JavaScript
  • No dependencies
  • Coerces foreign symbols to their english equivalent (check out the charMap in index.js for more details)
  • Works in the browser (window.slugify) and AMD/CommonJS-flavored module loaders

Out of the box slugify comes with support for a handfull of Unicode symbols. For example the (radioactive) symbol is not defined in the charMap object in index.js and therefore it will be stripped by default:

slugify('unicode ♥ is ☢') // unicode-love-is

However you can extend the supported symbols, or override the existing ones with your own:

slugify.extend({'': 'radioactive'})
slugify('unicode ♥ is ☢') // unicode-love-is-radioactive

Keep in mind that the extend method extends/overrides the default charMap for the entire process. In case you need a fresh instance of the slugify's charMap object you have to clean up the module cache first:

delete require.cache[require.resolve('slugify')]
var slugify = require('slugify')

This module was originally a vanilla javascript port of node-slug.
Note that the original slug module has been ported to vanilla javascript too.
One major difference between the two modules is that slugify does not depend on the external unicode module.