March 20267 min readFor Developers

camelCase vs snake_case: The Developer's Complete Guide

By caseconvert.me team

If you have spent any time writing code, you have faced this decision dozens of times: should this variable be getUserData or get_user_data? Should this function be calculateTotal or calculate_total?

The answer is not always obvious — and it depends heavily on the language you are working in, the team conventions you are following, and sometimes the specific context within a single project.

This guide breaks down camelCase vs snake_case completely: what each one is, which languages prefer which, when to use each, and how to convert between them instantly.

What is camelCase?

camelCase is a naming convention where words are joined together without spaces or separators, with the first word in lowercase and each subsequent word starting with an uppercase letter. The name comes from the way the capitalised letters resemble the humps of a camel. Examples:

javascript
getUserData
backgroundColor
isLoggedIn
calculateTotalPrice
fetchUserProfileById

There are two variants worth knowing. The standard version — where the first word is lowercase — is sometimes called lowerCamelCase or dromedaryCase. The variant where every word including the first starts with a capital letter (UserProfile, GetData) is called UpperCamelCase or PascalCase, and is treated as a separate convention.

What is snake_case?

snake_case is a naming convention where all letters are lowercase and words are separated by underscores. The name comes from the way underscores lie flat on the baseline, like a snake on the ground. Examples:

javascript
get_user_data
first_name
background_color
is_logged_in
calculate_total_price
fetch_user_profile_by_id

There is also SCREAMING_SNAKE_CASE — the same convention but with all uppercase letters. This is used specifically for constants and environment variables: DATABASE_URL, MAX_RETRY_COUNT, API_SECRET_KEY.

camelCase vs snake_case: Side-by-Side Comparison

FeaturecamelCasesnake_caseSCREAMING_SNAKE
SeparatorNone (caps)UnderscoreUnderscore
First letterLowercaseLowercaseUppercase
ReadabilityGoodVery goodGood (constants)
Typing speedFastSlightly slowerSlower
URL-safe?YesYesYes
Case-sensitive?YesYesYes

Which Languages Use camelCase?

camelCase is the dominant convention in most object-oriented and C-style languages. If you are working in any of the following, camelCase is almost certainly the expected standard:

LanguagecamelCase Used ForExample
JavaScriptVariables, functions, object keysconst getUserData = () => {}
TypeScriptVariables, functions, interfaces (lower)let firstName: string
JavaVariables, methodspublic void getUserData()
SwiftVariables, functions, propertiesvar userName: String
KotlinVariables, functionsfun getUserProfile(): User
Dart / FlutterVariables, functionsString firstName
JSONObject keys (by convention){ "userId": 1 }

Which Languages Use snake_case?

snake_case is the standard in Python, Ruby, and most database contexts. It is also the default for file naming in many ecosystems:

Language / Contextsnake_case Used ForExample
PythonVariables, functions, modules (PEP 8)def get_user_data():
RubyVariables, methods, symbolsdef get_user_profile
SQLColumn names, table namesuser_id, created_at
PostgreSQL / MySQLAll identifiersSELECT first_name FROM users
RustVariables, functionsfn get_user_data() -> User
PHPVariables, functions (PSR-12)$user_name, get_user_data()
File namingPython scripts, config filesuser_profile.py, api_config.json

The JavaScript Special Case: Both at Once

JavaScript projects often use both conventions simultaneously — and this causes the most confusion for developers. Here is the standard breakdown for a typical JavaScript or Node.js project:

javascript
// Variables and functions → camelCase
const getUserData = async (userId) => {
  const firstName = user.firstName;
  return firstName;
};

// Classes and React components → PascalCase
class UserProfile extends Component {}
const NavBar = () => <nav />;

// Constants → SCREAMING_SNAKE_CASE
const MAX_RETRY_COUNT = 3;
const API_BASE_URL = process.env.API_BASE_URL;

// CSS class names and HTML attributes → kebab-case
// <div class='nav-bar' data-user-id='1'>

When working with a Python backend and a JavaScript frontend, you will often need to convert between conventions. A Python API returns snake_case JSON keys (user_id, first_name), while your JavaScript frontend expects camelCase (userId, firstName). Many teams handle this with a serialisation layer — or use a converter tool to quickly check their naming.

Python: Why snake_case Is Non-Negotiable

Python has an official style guide — PEP 8 — that explicitly defines naming conventions. For most Python developers, following PEP 8 is not optional: it is expected by the community, enforced by linters (pylint, flake8), and required by most open-source contribution guidelines

Python
# PEP 8 compliant Python
def calculate_total_price(item_price, quantity):
    total_price = item_price * quantity
    return total_price

# Non-compliant (would fail a linter)
def calculateTotalPrice(itemPrice, quantity):
    totalPrice = itemPrice * quantity
    return totalPrice

This is one of the most common sources of frustration for developers moving from JavaScript to Python — the muscle memory for camelCase keeps firing in a codebase that expects snake_case. Tools that convert between the two are genuinely useful for this transition period.

Quick Reference: When to Use Which

SituationUse camelCaseUse snake_case
JavaScript variableuserNameuser_name
Python functiongetUserData()get_user_data()
SQL columnuserIduser_id
React proponClick, isVisibleon_click, is_visible
Python module nameUserProfileuser_profile
Environment variableapiSecretKeyAPI_SECRET_KEY
JSON API response keyfirstName (JS APIs)first_name (Python APIs)

How to Convert Between camelCase and snake_case

Converting between the two is a common task when working across language boundaries. You can do it manually, write a quick function, or use an online converter.

JavaScript function to convert camelCase to snake_case:

javascript
const camelToSnake = (str) =>
  str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);

camelToSnake('getUserData');   // 'get_user_data'
camelToSnake('firstName');     // 'first_name'
camelToSnake('isLoggedIn');    // 'is_logged_in'

Python function to convert snake_case to camelCase:

Python
def snake_to_camel(name):
    components = name.split('_')
    return components[0] + ''.join(x.title() for x in components[1:])

snake_to_camel('get_user_data')   # 'getUserData'
snake_to_camel('first_name')      # 'firstName'
snake_to_camel('is_logged_in')    # 'isLoggedIn'

Or use the free converter at caseconvert.me — paste your text, click camelCase or snake_case, and copy the result instantly.

The camelCase vs snake_case debate is not really a debate — it is a context question. The right answer depends entirely on the language, the framework, and the team conventions you are working within.

The simple rule: follow the language's official style guide. Use camelCase in JavaScript, Java, and Swift. Use snake_case in Python, Ruby, and SQL. When working across language boundaries, know how to convert between them quickly.

If you work across multiple languages daily, bookmark caseconvert.me — it converts between all case formats instantly, with no signup required.

Convert between camelCase and snake_case instantly → caseconvert.me

Use the Free Converter →