Skip to content
MoneyDeck

camelCase / snake_case Converter

Convert variable names between camelCase, snake_case, kebab-case and more

Updated · Free, no signup

Converted

get_user_profile
user_profile_id
xml_http_request
background_color
max_retry_count

camelCase

getUserProfile
userProfileId
xmlHttpRequest
backgroundColor
maxRetryCount

PascalCase

GetUserProfile
UserProfileId
XmlHttpRequest
BackgroundColor
MaxRetryCount

snake_case

get_user_profile
user_profile_id
xml_http_request
background_color
max_retry_count

kebab-case

get-user-profile
user-profile-id
xml-http-request
background-color
max-retry-count

CONSTANT_CASE

GET_USER_PROFILE
USER_PROFILE_ID
XML_HTTP_REQUEST
BACKGROUND_COLOR
MAX_RETRY_COUNT

Identifiers converted

5

Detected style (first line)

camelCase

Word breakdown

InputWords foundDetected style
getUserProfileget · user · profilecamelCase
user_profile_iduser · profile · idsnake_case
XMLHttpRequestxml · http · requestPascalCase
background-colorbackground · colorkebab-case
MAX_RETRY_COUNTmax · retry · countCONSTANT_CASE

About the camelCase / snake_case Converter

This case style converter rewrites variable, function, column and file names from one naming convention to another. Paste a single identifier or a list with one per line — getUserProfile, user_profile_id, background-color, MAX_RETRY_COUNT, or plain words — and get it back in camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case, COBOL-CASE, Train-Case, dot.case, path/case, flatcase, Title Case or Sentence case.

Developers use it when mapping database columns (usually snake_case) to JavaScript or Java properties (camelCase), turning React component names (PascalCase) into file or CSS class names (kebab-case), writing environment variables (CONSTANT_CASE), or renaming JSON keys between APIs. The most common targets are also shown side by side so you can copy whichever you need.

Words are detected at underscores, hyphens, dots, slashes, spaces and lower-to-upper case changes. Runs of capitals are treated as acronyms, so XMLHttpRequest becomes xml_http_request, and digits stay attached to the word before them, so base64Encode becomes base64_encode.

How to use the camelcase / snake_case converter

  1. 1Paste one identifier, or several with one per line.
  2. 2Choose the naming style to convert to.
  3. 3Copy the converted list, or grab camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE from the side-by-side outputs.
  4. 4Check the word breakdown table if a name split differently than you expected.

Formula and method

identifier → split into words → lowercase → re-join with the target separator and capitalisation

Conversion happens in two steps. First the input is split into words: a boundary is placed wherever a lowercase letter or digit is followed by a capital (userId → user Id), before the last capital of an acronym that runs into a capitalised word (XMLHttp → XML Http), and at any character that is not a letter or digit (underscore, hyphen, dot, slash, space). Every word is lowercased.

Then the words are re-joined using the rules of the target style: camelCase capitalises every word except the first and uses no separator, PascalCase capitalises every word, snake_case joins with underscores, kebab-case with hyphens, dot.case with dots, and CONSTANT_CASE and COBOL-CASE are the upper-case versions of snake and kebab. Because acronyms are lowercased first, the conversion is consistent in both directions (xmlHttpRequest ↔ xml_http_request).

Worked examples

Mixed list to snake_case

Each line is split into words at case changes, underscores and hyphens, then joined with underscores in lower case. XMLHttpRequest is read as the acronym XML followed by Http and Request, giving xml_http_request.

Database columns to camelCase properties

snake_case columns become camelCase by capitalising every word after the first and removing the underscores; PascalCase also capitalises the first word.

Component name to a CSS class and constant

The PascalCase component name splits into user, avatar and card. Joined with hyphens it is a typical CSS class or file name; upper-cased with underscores it becomes a constant.

Frequently asked questions

What is the difference between camelCase and PascalCase?+

Both remove spaces and capitalise each word, but camelCase starts with a lowercase letter (userName) while PascalCase, also called UpperCamelCase, capitalises the first word too (UserName). PascalCase is normally used for classes, types and React components; camelCase for variables and functions.

Which languages use snake_case?+

Python (PEP 8) uses snake_case for variables and functions, as do Ruby and Rust. It is also the most common style for SQL table and column names. Constants in most languages use CONSTANT_CASE, the upper-case form.

When should I use kebab-case?+

Use kebab-case where hyphens are allowed and identifiers are not code variables: URLs and slugs, CSS class names and custom properties, HTML attributes, file names, npm package names and command-line flags. In most programming languages a hyphen would be read as subtraction.

How are acronyms like HTML or ID handled?+

A run of capitals is treated as one word, so parseHTMLString becomes parse_html_string and userID becomes user_id. When converting back to camelCase the acronym is written as a normal word (parseHtmlString), which matches the Google Java Style Guide (XmlHttpRequest, not XMLHTTPRequest). Some conventions, such as .NET’s, keep two-letter acronyms upper case (IOStream), so check your team’s style guide.

What is CONSTANT_CASE?+

CONSTANT_CASE (also called SCREAMING_SNAKE_CASE) is snake_case in capital letters, such as MAX_RETRY_COUNT. It is the convention for constants and environment variables in JavaScript, Java, Python, C and shell scripts.

Related tools