Camel Case String To Snake Case String
What is Camel Case?
Camel case is a naming convention in which a word or phrase is written without spaces between words and each word is capitalized except for the first word.
What is Snake Case?
Snake case is a naming convention in which a word or phrase is written without spaces between words and each word is separated by an underscore.
How to convert Camel Case String to Snake Case String?
To convert Camel Case String to Snake Case String, we need to split the string into words, then convert each word to lowercase, then join the words together with an underscore.
Example
Let's convert the string "helloWorld" to Snake Case String.
First, we need to split the string into words.
String | Words |
---|---|
helloWorld | hello, World |
Now, we need to convert each word to lowercase.
Words | Lowercase Words |
---|---|
hello, World | hello, world |
Finally, we need to join the words together with an underscore. In this case, the final Snake Case String is hello_world. This is the Snake Case String representation of the string "helloWorld".
Become a Sponsor![Heart with ribbon](/_next/image?url=%2Fheart-with-ribbon.png&w=48&q=75)
Become a sponsor and help us maintain and improve this project. Every contribution counts. Thank you!