30 seconds of code

String

Click on a snippet card to view the snippet.

CSVToArray

Converts a comma-separated values (CSV) string to a 2D array.

CSVToJSON

Converts a comma-separated values (CSV) string to a 2D array of objects. The first row of the string is used as the title row.

URLJoin

Joins all given URL segments together, then normalizes the resulting URL.

byteSize

Returns the length of a string in bytes.

capitalize

Capitalizes the first letter of a string.

capitalizeEveryWord

Capitalizes the first letter of every word in a string.

compactWhitespace

Returns a string with whitespaces compacted.

decapitalize

Decapitalizes the first letter of a string.

escapeHTML

Escapes a string for use in HTML.

escapeRegExp

Escapes a string to use in a regular expression.

fromCamelCase

Converts a string from camelcase.

indentString

Indents each line in the provided string.

isAbsoluteURL

Returns true if the given string is an absolute URL, false otherwise.

isAnagram

Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

isLowerCase

Checks if a string is lower case.

isUpperCase

Checks if a string is upper case.

mapString

Creates a new string with the results of calling a provided function on every character in the calling string.

mask

Replaces all but the last num of characters with the specified mask character.

pad

Pads a string on both sides with the specified character, if it's shorter than the specified length.

palindrome

Returns true if the given string is a palindrome, false otherwise.

pluralize

Returns the singular or plural form of the word based on the input number. If the first argument is an object, it will use a closure by returning a function that can auto-pluralize words that don't simply end in s if the supplied dictionary contains the word.

removeNonASCII

Removes non-printable ASCII characters.

reverseString

Reverses a string.

sortCharactersInString

Alphabetically sorts the characters in a string.

splitLines

Splits a multiline string into an array of lines.

stringPermutations

⚠️ WARNING: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.

Generates all permutations of a string (contains duplicates).

stripHTMLTags

Removes HTML/XML tags from string.

toCamelCase

Converts a string to camelcase.

toKebabCase

Converts a string to kebab case.

toSnakeCase

Converts a string to snake case.

toTitleCase

Converts a string to title case.

truncateString

Truncates a string up to a specified length.

unescapeHTML

Unescapes escaped HTML characters.

words

Converts a given string into an array of words.