Comparison 5 min read

camelCase vs snake_case vs kebab-case: Which Naming Style to Use

camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE explained: what each looks like, where each language expects it, and how to convert names fast.

camelcase vs snake casekebab casepascal case vs camel casenaming conventions programmingconvert to snake caseconstant case

The short answer

Use the style your language or file type already expects: camelCase for variables and functions in JavaScript and Java, PascalCase for class and component names, snake_case for Python variables, functions and most database columns, kebab-case for URLs, CSS classes and file names, and CONSTANT_CASE for fixed values. To convert a phrase into any of them, type the words with spaces into the Case Converter and click the style you need.

What each style looks like

Here is the same phrase, "user first name", written in each style. These outputs come straight from the Case Converter.

StyleExampleRule
camelCaseuserFirstNameFirst word lower case, every later word starts with a capital
PascalCaseUserFirstNameEvery word starts with a capital, including the first
snake_caseuser_first_nameAll lower case, words joined by underscores
kebab-caseuser-first-nameAll lower case, words joined by hyphens
CONSTANT_CASEUSER_FIRST_NAMEAll upper case, words joined by underscores

The names describe the shape. camelCase has a "hump" in the middle, snake_case lies flat along the ground, and kebab-case looks like words on a skewer. PascalCase is also called "upper camel case", and CONSTANT_CASE is sometimes called "screaming snake case".

Where each style is normally used

These are the common conventions. Your team's style guide or linter always wins over this list, so check it first.

camelCase

  • Variables and functions in JavaScript and TypeScript, such as totalPrice or getUserName().
  • Variables and methods in Java, Kotlin and Swift.
  • Keys in many JSON APIs, although some APIs use snake_case instead. Match whatever the API already returns.

PascalCase

  • Class names in most object-oriented languages: InvoiceGenerator, UserProfile.
  • React and Vue component names, such as LoginForm.
  • Type and interface names in TypeScript.

snake_case

  • Variables, functions and module names in Python, as recommended by PEP 8, the Python style guide.
  • Database table and column names, such as order_items.created_at. Many databases fold unquoted names to one case, so mixed-case names like createdAt can cause confusing errors.
  • Variables and functions in Ruby and Rust.

kebab-case

  • URL slugs: /blog/how-to-reset-password. Hyphens are easy to read in a link and do not get hidden by an underline the way underscores can.
  • CSS class names and custom properties, such as .nav-menu or --brand-color.
  • File and folder names in many web projects, and command-line flags such as --dry-run.

You cannot use kebab-case for variable names in most programming languages, because user-name is read as "user minus name".

CONSTANT_CASE

  • Values that never change: MAX_RETRIES, API_BASE_URL.
  • Environment variables, such as DATABASE_URL or NODE_ENV.

Quick comparison: which one should you pick?

SituationUse
JavaScript variable or functioncamelCase
Python variable or functionsnake_case
Class, React component or typePascalCase
Database columnsnake_case
URL, CSS class, file namekebab-case
Constant or environment variableCONSTANT_CASE

If a project mixes styles in one layer, for example some columns in camelCase and some in snake_case, pick the style that is already in the majority and convert the rest gradually. Consistency matters more than which style you choose.

How to convert names with the Case Converter

  • Open the Case Converter.
  • Type or paste your phrase with the words separated by spaces, for example max retry count.
  • Click a style button: camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE. The result appears below straight away.
  • Click Copy result and paste it into your code.
  • You can paste several lines at once, but in all five code styles a line break counts as a separator, so a list of three phrases on three lines turns into one long joined name. Convert one name at a time when you need separate results.

    What the converter does with tricky input

    Knowing the exact rules helps you avoid surprises. These examples were run through the tool's conversion code.

    It does not split existing camelCase

    The converter finds word boundaries only at spaces, hyphens, underscores and other non-letter characters. It does not detect the capital letters inside an existing camelCase name. So getUserName converted to snake_case becomes getusername, not get_user_name.

    Fix: type the name with spaces first (get user name), then convert. The same applies when going from PascalCase to kebab-case.

    Acronyms are flattened

    User ID number becomes userIdNumber in camelCase and user_id_number in snake_case. Most style guides prefer this (userId rather than userID), but if your codebase keeps acronyms in capitals, fix those letters by hand.

    Punctuation at the end

    Symbols are treated as separators. max retry count! becomes max_retry_count in snake_case and max-retry-count in kebab-case, because leading and trailing separators are trimmed. CONSTANT_CASE does not trim them, so the same input gives MAX_RETRY_COUNT_. Remove trailing punctuation before converting to CONSTANT_CASE.

    Only English letters and digits are kept

    For snake_case, kebab-case, camelCase and PascalCase, anything other than A to Z and 0 to 9 counts as a separator. Accented letters such as é are treated as separators, so café menu turns into caf_menu in snake_case. Variable names should normally use plain ASCII letters anyway, so replace accented characters before converting.

    Sentence case only capitalises the very first letter

    The converter also has text styles (UPPER CASE, lower case, Title Case, Sentence case and two novelty styles). Its Sentence case lowercases everything and capitalises only the first character of the whole text, so hello world. this is it becomes Hello world. this is it. For normal prose case changes, see how to convert text case and check each sentence start.

    Common mistakes

    • Mixing styles in one API. Returning user_id in one endpoint and userId in another forces every client to handle both.
    • Using underscores in URLs. Hyphens are the usual word separator in web addresses and are easier to read when a link is underlined. Keep slugs in kebab-case.
    • Changing a database column name without updating queries. Renaming createdAt to created_at is a schema change. Search the codebase for the old name first, for example with Find and Replace on a pasted file.
    • Starting a name with a digit. 2fa_enabled is not a valid identifier in most languages. Use two_factor_enabled instead.

    Related tools

    Frequently asked questions

    What is the difference between camelCase and PascalCase?

    Both join words without spaces and capitalise each word, but camelCase keeps the first word lower case (userFirstName) while PascalCase capitalises it too (UserFirstName). PascalCase is usually used for class and component names.

    Should I use snake_case or camelCase?

    Follow the language: snake_case for Python and most database columns, camelCase for JavaScript, TypeScript and Java variables. Inside one project, consistency matters more than the choice itself.

    Why is kebab-case not used for variable names?

    Most programming languages read the hyphen as a minus sign, so user-name would mean user minus name. Kebab-case is used for URLs, CSS classes and file names instead.

    Can the Case Converter turn getUserName into get_user_name?

    Not directly. It only splits words at spaces and symbols, so getUserName becomes getusername. Type it as get user name first, then choose snake_case.

    Try this tool on Lazyblink

    Put this guide into practice with our free online tool — no signup required.

    Open tool