camelCase vs snake case vs kebab-case: Which to Use and How to Convert
camelCase vs snake case vs kebab-case: which style each language and URL expects, the rules from PEP 8 and Google, and how to convert names correctly.
By TheTextKit TeamPublished

A card lists the name user first name in five styles. camelCase is userFirstName, PascalCase is UserFirstName, snake_case is user_first_name, kebab-case is user-first-name and CONSTANT_CASE is USER_FIRST_NAME. Each style has a colored label.
camelCase vs snake_case vs kebab-case is a choice between three ways to write a name that has several words in it, in places where a space is not allowed. They look like a matter of taste, but each language, format and web address has a convention, and breaking it makes code harder to read and URLs harder for search engines to understand. This guide sets out which style goes where, with the rules from the official style guides, and shows how a converter should treat the awkward cases such as acronyms. We also found that our own converter got many of them wrong and fixed it.
The same name in five styles
Here is one name, written in each of the five styles the Case Converter supports:
| Style | Example | Rule |
|---|---|---|
| camelCase | userFirstName | First word lowercase, each other word starts with a capital |
| PascalCase | UserFirstName | Every word starts with a capital |
| snake_case | user_first_name | All lowercase, words joined with underscores |
| kebab-case | user-first-name | All lowercase, words joined with hyphens |
| CONSTANT_CASE | USER_FIRST_NAME | All capitals, words joined with underscores |
The names come from the way they look. camelCase has humps in the middle, snake_case lies along the ground, and kebab-case looks like words on a skewer. They all carry the same information, and a good converter can move between any two of them.
camelCase vs snake_case: which style goes where
The right choice is whatever the place you are writing expects. We checked the official sources:
| Where | Style | Source |
|---|---|---|
| Python functions and variables | snake_case | PEP 8 |
| Python classes | CapWords (PascalCase) | PEP 8 |
| Python constants | ALL_CAPS_WITH_UNDERSCORES | PEP 8 |
| JavaScript variables and methods | lowerCamelCase | Google JavaScript Style Guide |
| JavaScript classes | UpperCamelCase | Google JavaScript Style Guide |
| JavaScript constants | CONSTANT_CASE | Google JavaScript Style Guide |
| URLs | kebab-case | Google URL structure guidance |
PEP 8 adds that mixedCase, which is another name for camelCase, is allowed only where it is already the prevailing style, to keep backward compatibility. The Google JavaScript Style Guide also says that file names are all lowercase with underscores or dashes.

A table of four places and the naming style each expects. Python variables and functions use snake case. JavaScript variables and methods use camel case. JavaScript constants use constant case. URLs use kebab case.
CSS follows the same pattern. Its properties, such as background-color and font-size, are written in kebab-case, so class names in that style fit naturally next to them.
Hyphens and underscores in URLs
Google's URL structure guidance recommends hyphens instead of underscores to separate words, because hyphens help users and search engines identify the concepts in the URL. It notes that underscores have long been used in programming to join connected concepts, which makes it unclear whether the words are meant to be read together or apart. Its example is summer-clothing against summer_clothing. Our guide to URL slug best practices covers the rest of the rules for slugs.

Two cards compare two URL paths. The path with a hyphen, summer-clothing, is marked as recommended by Google. The path with an underscore, summer_clothing, is marked as not recommended.
Is one style easier to read?
People have argued about this for decades, and there is some evidence. A 2013 study in Empirical Software Engineering by Binkley and colleagues tested camelCase and underscore identifiers in five studies with 150 participants. It found that beginner programmers did better with camelCase, while experienced programmers were not affected by the style. The practical lesson is that, in the camelCase vs snake_case debate, consistency matters more than the choice. Mixing styles in one codebase costs more than either style does.
How a converter should split a name
A converter first has to find the words. For user first name that is easy. The hard cases are names that are already joined:
| Input | camelCase | snake_case |
|---|---|---|
XMLHttpRequest | xmlHttpRequest | xml_http_request |
getHTTPResponse | getHttpResponse | get_http_response |
YouTube importer | youTubeImporter | you_tube_importer |
es6 module | es6Module | es6_module |
The Google JavaScript Style Guide gives a four-step method. First convert to ASCII and remove apostrophes. Then split the text into words at spaces and punctuation. Next lowercase everything and capitalize the first letter of the words that need it. Last, join the words. It says an acronym is treated as an ordinary word, so XML HTTP request becomes xmlHttpRequest and not XMLHTTPRequest. Our converter gives the same results for the guide's two examples, xmlHttpRequest and youTubeImporter.

A table of three conversions of the name XMLHttpRequest. camelCase gives xmlHttpRequest. snake case gives xml underscore http underscore request. kebab case gives xml hyphen http hyphen request.
What simple converters get wrong
Our previous converter removed every character that was not a plain English letter or digit, and it never looked for word boundaries inside a name. We ran it against the new one on typical inputs:
| Input | Style | Old converter | New converter |
|---|---|---|---|
café au lait | camelCase | cafAuLait | caféAuLait |
HELLO WORLD | camelCase | hELLOWORLD | helloWorld |
don't stop | camelCase | donTStop | dontStop |
helloWorld | snake_case | helloworld | hello_world |
foo-bar.baz | snake_case | foobarbaz | foo_bar_baz |
Café Crème | snake_case | caf_crme | café_crème |
camelCaseName | kebab-case | camelcasename | camel-case-name |
Accented letters were deleted, a name that was already camelCase lost its word boundaries, and an apostrophe turned don't into donTStop. To measure the damage, we compared both converters with the widely used lodash library on 20,000 random names built from words with separators, capitals, acronyms and accents. The old camelCase converter differed from lodash on 15,339 of them, the snake_case one on 16,748 and the kebab-case one on 16,671. The new converter matched lodash on every one, in all five styles, which is 100,000 conversions.

A table of three styles tested on 20,000 random names. The old camel case converter differed from lodash on 15,339 names, the snake case one on 16,748 and the kebab case one on 16,671. The new converter differed on none.
One difference from lodash is on purpose. Lodash puts a digit in a word of its own, so es6 module becomes es_6_module. Our converter keeps digits attached to the word before them and gives es6_module, which is how most people write such names. We left digits out of the comparison for that reason.
When to use each style
- camelCase for variables, parameters and methods in JavaScript and Java, where the style guides ask for it.
- PascalCase for class names and types, which most languages write with a capital on every word.
- snake_case for Python variables and functions and for database columns, where a lowercase name needs no quoting.
- kebab-case for CSS classes, file names and URL slugs. It cannot be used as a name in most programming languages, because the hyphen reads as a minus sign.
- CONSTANT_CASE for constants and environment variables, so they stand out from ordinary names.
If you work in more than one language, expect to convert between styles often. The same field may be user_first_name in the database, userFirstName in the JavaScript that reads it and user-first-name in a CSS class.
Tips for converting names
- Convert a list one line at a time. The Case Converter treats each line as one name, so a column of field names stays a column.
- Remove accents when you need plain ASCII. Identifiers and file names are often safer without accents. The converter's option turns
éintoeandßintoss. - Write acronyms as words.
userIdandparseHttpResponseconvert both ways without loss.parseHTTPResponsealso works with our converter, but a different tool may read it differently. - Rename in bulk with care. After converting names, a find and replace across your files can update them. Test the pattern in the Regex Tester first, and add word boundaries so
iddoes not match insidevideo.
Frequently asked questions
What is the difference between camelCase and snake_case?
camelCase joins words with no separator and capitalizes each word after the first, as in userFirstName. snake_case writes every word in lowercase and joins them with underscores, as in user_first_name. The first is usual in JavaScript and Java, the second in Python and SQL.
Which case does Python use?
PEP 8 says function and variable names should be lowercase with words separated by underscores. Class names use CapWords, and constants are written in capital letters with underscores. mixedCase is allowed only where it is already the prevailing style.
Should URLs use hyphens or underscores?
Hyphens. Google recommends hyphens instead of underscores to separate words in URLs, because they help users and search engines identify the words. Use kebab-case for slugs, for example summer-clothing and not summer_clothing.
How do I write an acronym in camelCase?
Treat it as a normal word. Google's JavaScript style guide turns XML HTTP request into xmlHttpRequest, not XMLHTTPRequest. That keeps the word boundaries visible and makes conversion to other styles reliable.
Is camelCase or snake_case easier to read?
It depends on the reader. A 2013 study by Binkley and colleagues found that beginners did better with camelCase, while experienced programmers were not affected by the style. Choose the convention of your language or project and apply it everywhere.
Convert your names now
Whichever side of camelCase vs snake_case you choose, paste a name or a list into the Case Converter, pick a style and copy the result. It splits camelCase and acronyms, keeps accented letters unless you ask it not to, and works on each line separately.


