CalculatorsConvertersDeveloperTextAll toolsDirectory
Submit your tool Sign in
Theme
Home/Answers/Developer
How-to

How do I convert variable names between camelCase and snake_case?

Short answer

Split the identifier at its word boundaries, then rejoin the words in the target style: firstName becomes first_name and back again. A browser-based case style converter does this for whole lists of identifiers at once, converting between camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE on your own device, which is handy when moving names between languages like JavaScript and Python.

Why the same name has many shapes

Different ecosystems standardize different identifier styles: JavaScript and Java favor camelCase, Python and Ruby favor snake_case, CSS classes and URLs use kebab-case, environment variables and constants use CONSTANT_CASE, and class names are commonly PascalCase. The moment data crosses a boundary, a JSON API feeding a Python service, or a database schema surfacing in a JavaScript client, someone has to convert names accurately.

Convert in bulk, not by hand

Renaming one identifier is easy; renaming forty fields without a typo is not. A case style converter takes your list of names and outputs them in the target convention, handling the word-boundary detection for you, including digits and acronyms that make hand-conversion error prone. A companion tool shows one input in every case style at once when you just need all the variants.

Private by construction

Field and variable names can reveal a lot about an internal schema. The conversion runs entirely in your browser, so your identifier list is never sent anywhere.

Step by step

  1. Collect the names. Copy the identifiers you need to convert, one per line works well.
  2. Paste into the converter. Open the case style converter and paste the list.
  3. Pick the target style. Choose camelCase, snake_case, kebab-case, PascalCase or CONSTANT_CASE.
  4. Copy the result. Copy the converted list into your code, schema or config.

Frequently asked questions

Which styles can it convert between?

camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE and dot.case, in any direction.

Can I convert many names at once?

Yes. Paste a list and the whole set is converted in one go.

Are my identifiers sent to a server?

No. The conversion runs entirely in your browser.

Related answers