diff --git a/README.md b/README.md
index b68f397e5..a94176aca 100644
--- a/README.md
+++ b/README.md
@@ -143,6 +143,7 @@
* [`reverseString`](#reversestring)
* [`sortCharactersInString`](#sortcharactersinstring)
* [`toCamelCase`](#tocamelcase)
+* [`toSnakeCase`](#tosnakecase)
* [`truncateString`](#truncatestring)
* [`words`](#words)
@@ -1968,6 +1969,23 @@ const toCamelCase = str =>
[⬆ back to top](#table-of-contents)
+### toSnakeCase
+
+Converts a string to snakecase.
+
+Use `replace()` to add underscores before capital letters, convert `toLowerCase()`, then `replace()` hyphens and spaces with underscores.
+
+```js
+const toSnakeCase = str =>
+ str.replace(/(\w)([A-Z])/g, '$1_$2').replace(/[\s-_]+/g, '_').toLowerCase();
+// toSnakeCase("camelCase") -> 'camel_case'
+// toSnakeCase("some text") -> 'some_text'
+// toSnakeCase("some-javascript-property") -> 'some_javascript_property'
+// toSnakeCase("some-mixed_string With spaces_underscores-and-hyphens") -> 'some_mixed_string_with_spaces_underscores_and_hyphens'
+```
+
+[⬆ back to top](#table-of-contents)
+
### truncateString
Truncates a string up to a specified length.
diff --git a/docs/index.html b/docs/index.html
index dc8296a8e..7e2d8ff1a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -171,6 +171,7 @@
reverseString
sortCharactersInString
toCamelCase
+toSnakeCase
truncateString
words
@@ -1214,6 +1215,16 @@ Combine characters to get a string using join('').
Converts a string to snakecase.
+Use replace() to add underscores before capital letters, convert toLowerCase(), then replace() hyphens and spaces with underscores.
const toSnakeCase = str =>
+ str.replace(/(\w)([A-Z])/g, '$1_$2').replace(/[\s-_]+/g, '_').toLowerCase();
+// toSnakeCase("camelCase") -> 'camel_case'
+// toSnakeCase("some text") -> 'some_text'
+// toSnakeCase("some-javascript-property") -> 'some_javascript_property'
+// toSnakeCase("some-mixed_string With spaces_underscores-and-hyphens") -> 'some_mixed_string_with_spaces_underscores_and_hyphens'
+
Truncates a string up to a specified length.
Determine if the string's length is greater than num.