Text Case Converter

camelCase vs snake_case vs kebab-case: Which Should You Use?

📅 April 2026 ⏱ 6 min read ✍️ ToolsBox

If you have spent any time writing code, you have run into the naming question: should this variable be userFirstName, user_first_name, or user-first-name? The answer depends on the language, context and convention. This guide covers every major naming style, when each is appropriate, and how to convert between them instantly.

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 / ContextVariables & FunctionsClassesConstantsFiles / URLs
JavaScript / TypeScriptcamelCasePascalCaseUPPER_SNAKE_CASEkebab-case
Pythonsnake_casePascalCaseUPPER_SNAKE_CASEsnake_case
JavacamelCasePascalCaseUPPER_SNAKE_CASEcamelCase
PHPcamelCase / snake_casePascalCaseUPPER_SNAKE_CASEkebab-case
Rubysnake_casePascalCaseUPPER_SNAKE_CASEsnake_case
GocamelCasePascalCasePascalCasesnake_case
CSS / HTML attributeskebab-casekebab-case
Database columns (SQL)snake_casesnake_case
URLs / slugskebab-casekebab-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-compressor is 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.

  1. Paste your text into the converter.
  2. Click the target case: camelCase, snake_case, kebab-case, PascalCase, UPPERCASE and more.
  3. Copy the result directly.

Convert text case instantly — free

camelCase, snake_case, kebab-case, PascalCase and more in one click.
Open Text Case Converter →

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