The Five Main Naming Conventions
camelCase
Words are joined without spaces. Every word after the first begins with a capital letter. The name comes from the humps that the capital letters create.
Examples: getUserName, totalPrice, isLoggedIn, firstName
PascalCase (UpperCamelCase)
Same as camelCase but the very first letter is also capitalised. Often called UpperCamelCase.
Examples: UserProfile, ShoppingCart, ProductController
snake_case
Words are joined with underscores. All letters are lowercase (unless it is SCREAMING_SNAKE_CASE, which is uppercase throughout).
Examples: user_first_name, total_price, MAX_RETRY_COUNT
kebab-case
Words are joined with hyphens. All letters are lowercase. Named after the way items are skewered on a kebab.
Examples: user-profile, font-size, my-component
UPPERCASE / Title Case / Sentence case
All capitals (ERROR, STATUS) are used for constants. Title Case capitalises every word. Sentence case capitalises only the first word.
Which Convention for Which Language?
| Language / Context | Variables & Functions | Classes | Constants | Files / URLs |
|---|---|---|---|---|
| JavaScript / TypeScript | camelCase | PascalCase | UPPER_SNAKE_CASE | kebab-case |
| Python | snake_case | PascalCase | UPPER_SNAKE_CASE | snake_case |
| Java | camelCase | PascalCase | UPPER_SNAKE_CASE | camelCase |
| PHP | camelCase / snake_case | PascalCase | UPPER_SNAKE_CASE | kebab-case |
| Ruby | snake_case | PascalCase | UPPER_SNAKE_CASE | snake_case |
| Go | camelCase | PascalCase | PascalCase | snake_case |
| CSS / HTML attributes | kebab-case | — | — | kebab-case |
| Database columns (SQL) | snake_case | — | — | snake_case |
| URLs / slugs | kebab-case | — | — | kebab-case |
| JSON keys (API) | camelCase (JS) or snake_case (Python) | — | — | — |
Why Can't I Use kebab-case in JavaScript?
Hyphens are the subtraction operator in JavaScript. Writing user-name is interpreted as user minus name, which is a calculation, not a variable name. This is why kebab-case cannot be used for JavaScript variables or function names — the language syntax prevents it.
You can use it in object keys if you quote them: {"user-name": "Alice"}, but accessing it requires bracket notation: obj["user-name"] rather than obj.user-name.
Why Does Python Prefer snake_case?
Python's official style guide, PEP 8, specifies snake_case for variables, functions and module names. The Python community follows this convention very consistently, which means most Python code — including the standard library — uses snake_case. Deviating from it makes your code look non-idiomatic to other Python developers.
SEO and URLs: Always kebab-case
For URLs and file names on the web, kebab-case is universally preferred because:
- Google treats hyphens as word separators, so
best-image-compressoris read as three words. - Underscores in URLs are not treated as word separators by default in older Google crawlers.
- Hyphens are more readable for humans in a browser address bar.
- Spaces in URLs become
%20, which is ugly — hyphens avoid this entirely.
So toolsbox4u.com/image-compressor/ is better for SEO than toolsbox4u.com/imageCompressor/ or toolsbox4u.com/image_compressor/.
Convert Between Cases Instantly
If you need to reformat a batch of text — changing a column of database field names to camelCase for a JavaScript object, for example — do it in one step with the ToolsBox Text Case Converter.
- Paste your text into the converter.
- Click the target case: camelCase, snake_case, kebab-case, PascalCase, UPPERCASE and more.
- Copy the result directly.
Convert text case instantly — free
camelCase, snake_case, kebab-case, PascalCase and more in one click.Frequently Asked Questions
What is camelCase?
camelCase writes multiple words together with no spaces, capitalising the first letter of each word except the first. Examples: getUserName, totalPrice, isLoggedIn. It is the standard for JavaScript and Java variables and functions.
When should I use snake_case vs camelCase?
Use snake_case in Python (variables, functions, filenames) and SQL column names. Use camelCase in JavaScript and Java for variables and functions. PascalCase is used for class and component names across most languages.
Why is kebab-case used in CSS and URLs?
Hyphens are URL-safe and readable in addresses. CSS properties like font-size and border-radius use it. Kebab-case cannot be used as a JavaScript variable name because hyphens are interpreted as the subtraction operator.
How do I convert text between cases online?
Paste your text into the ToolsBox Text Case Converter and click the target case. It handles camelCase, snake_case, kebab-case, PascalCase, UPPERCASE and more instantly.
← Back to Blog | Related tool: Free Text Case Converter