Programming
camelCase, snake_case and kebab-case Explained
Names in code, files and web addresses can't have spaces. So people join the words in a set way. Three styles are everywhere.
The three styles
- camelCase joins the words and capitalizes each new one like
userFirstName. You'll see it a lot in JavaScript and Java. - snake_case uses lowercase words with underscores like
user_first_name. Python and many databases use it. - kebab-case uses lowercase words with hyphens like
user-first-name. It's common in web addresses and CSS class names.
Constants are often written as UPPER_SNAKE_CASE.
Which one should you pick?
Use whatever the language or project already uses. What matters most is being consistent. Mixed styles make code harder to read and search. If your team has a style guide it wins over any habit of yours.
Converting without errors
The Case Converter splits your text into words made of letters and numbers. Then it joins them in the style you pick. Punctuation is removed which is what you want for names.
Watch out for acronyms. A name like XMLParser has no spaces to split on so it's treated as one word. If you want xml_parser type a space between the words first.
Other cases
Title Case and Sentence case are for headings and normal writing. The converter has both along with UPPERCASE and lowercase. That makes it handy for fixing a pasted heading in one click.