Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


A collection of utility functions for working with strings in JavaScript in the browser or Node

Subscribe to updates I use slang

Statistics on slang

Number of watchers on Github 160
Number of open issues 3
Average time to close an issue less than a minute
Main language JavaScript
Average time to merge a PR 7 days
Open pull requests 2+
Closed pull requests 0+
Last commit almost 6 years ago
Repo Created over 8 years ago
Repo Last Updated over 1 year ago
Size 668 KB
Organization / Authordevongovett
Page Updated
Do you use slang? Leave a review!
View open issues (3)
View slang activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating slang for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


A collection of utility functions for working with strings in JavaScript in the browser or CommonJS.

Node Installation

npm install slang

Annotated source code

The annotated source code for slang, generated by Docco, can be found here.



Returns whether input is a string

slang.isString('testing'); // true
slang.isString(543);       // false


Capitalizes the first character of a string

slang.capitalize('hello world!'); // "Hello world!"


Uncapitalizes the first character of a string

slang.uncapitalize('Hello world!); // "hello world!"


Capitalizes each word in the string

slang.capitalizeWords('hello world!'); // "Hello World!"


Uncapitalizes each word in the string

slang.uncapitalizeWords('Hello World!'); // "hello world!"


Returns whether the character at the provided character index is upper case.

slang.isUpperCaseAt('Testing', 0); // true


Returns whether the character at the provided character index is lower case.

slang.isLowerCaseAt('Testing', 1); // true


Inverts the case for each letter in the string

slang.swapcase('aaBBccDD'); // "AAbbCCdd"


Converts a string of words seperated by dashes or spaces to camelCase

slang.camelize('hello world'); // "helloWorld"
slang.camelize('hello-world'); // "helloWorld"


slang.uncamelize('helloWorld'); // "hello World"


Converts a string of words or a camelCased string into a series of words separated by a dash (-)

slang.dasherize('this is dashed'); // "this-is-dashed"


Concatenates the string count times

slang.repeat('Ho! ', 3); // "Ho! Ho! Ho! "


Inserts string in input at index

slang.insert('this is cool!', 'really ', 8); // "this is really cool!"


Removes the characters between the start and end indexes

slang.remove('this is really cool!', 8, 15); // "this is cool!"


Removes the last character of input

slang.chop('hello'); // "hell"


Removes leading and trailing whitespace from input. Uses ES5's native trim is available.

slang.trim('hello '); // "hello"


Removes the leading whitespace from input

slang.trimLeft(' hello '); // "hello "


Removes the trailing whitespace from input

slang.trimRight(' hello '); // " hello"


Truncates input to args.limit or 10 and adds args.omission or ...

slang.truncate('Lorem ipsum dolor sit amet.');                                           // 'Lorem ipsu...'
slang.truncate('Lorem ipsum dolor sit amet.', { limit: 5, omission: '...(read more)' }); // 'Lorem...(read more)'


Joins an array into a humanized list. The last element is joined by and by default, but you can change it.

slang.join(['red', 'blue', 'green']);       // "red, blue and green"
slang.join(['red', 'blue', 'green'], 'or'); // "red, blue or green"


Returns a humanized number with the correct suffix such as 1st, 2nd, 3rd or 4th.

slang.humanize(2);   // "2nd"
slang.humanize(103); // "103rd"


Returns whether input contains string

slang.contains('hello world', 'world'); // true


Returns whether input starts with string

slang.startsWith('hello world', 'hello'); // true


Returns whether input ends with string

slang.endsWith('hello world', 'world'); // true


Returns whether input is empty or only contains whitespace

slang.isBlank(' '); // true
slang.isBlank('');  // true


Returns the successor to str. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case.

If the increment generates a carry, the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary.

slang.successor("abcd");      // "abce"
slang.successor("THX1138");   // "THX1139"
slang.successor("<<koala>>"); // "<<koalb>>"
slang.successor("1999zzz");   // "2000aaa"
slang.successor("ZZZ9999");   // "AAAA0000"


Returns a unique guid of the specified length, or 32 by default

slang.guid();   // "gE9FEtJknQVy3qkN9fxmTucYKTwFOno2"
slang.guid(15); // "b0apU4OH7ZgmEoU"


Adds the methods from the slang object to String.prototype. Does not add slang.guid, slang.humanize, slang.isString, slang.version, or itself.

"test".capitalize(); // "Test"


The default language to be used with all inflection methods. Initially set to 'en' for English.


Pluralizes a string in the specified language or slang.lang by default

inflector.pluralize('man') // 'men'
inflector.pluralize('word', 'de') // non-default language


Singularizes a string in the specified language or slang.lang by default

inflector.singularize('men') // 'man'
inflector.singularize('word', 'de') // non-default language


An object that describes a language's inflection rules. See source code for example usage.


An object holding slang.Language objects that describe various languages. English ('en') is provided by default and you can add additional languages by adding them to slang.languages. Then you can set the default language to this new language by setting slang.lang or just use your language by passing the language code as the second argument to slang.pluralize or slang.singularize.

// Create a language
var german = new slang.Language();
// Now add inflection rules
// ...

// Add language
slang.languages['de'] = german;

// Set default language
slang.lang = 'de';


slang is licensed under the MIT license.

slang open issues Ask a question     (View All Issues)
  • almost 6 years Issues with astral Unicode symbols
slang open pull requests (View All Pulls)
  • Added Meteor.js Package support
  • +added 'partition', and 'repartition'
slang questions on Stackoverflow (View All Questions)
  • How to Correct Slang words using python or Nltk?
  • How to handle slang words and short forms in Tweets like luv , kool and brb?
  • Where can I download the Slang sources to SqueakVM?
  • Slang-Dictionary as downloadable text file?
  • Plotting two "slang of graphics" layers in Gadfly
  • social media slang identifier
  • what is actually "EXTENT" in gis slang?
  • "Slang" large numbers in php?
  • python module to remove internet jargon/slang/acronym
  • TUI using slang with pure ascii (7 bit) characters via termcap
slang list of languages used
Other projects in JavaScript