snake_case to camelCase Converter (and Back)

Convert identifiers between snake_case, camelCase, PascalCase, kebab-case and CONSTANT_CASE. Handles HTTPServer-style acronyms, digits and leading underscores.

Loading tool…

Worked examples

  • Database columns to camelCase

    Typical ORM or API-mapping job: snake_case column names to JavaScript-style properties. The leading underscore on _internal_cache is kept.

  • camelCase with acronyms to snake_case

    Runs of capitals are treated as one acronym word until the next capitalized word starts, so HTTPServer is http_server rather than h_t_t_p_server.

  • Digits as their own words

    With the split-digits option on, digit runs become separate words, giving oauth-2-token; leave it off to keep oauth2-token.

What this tool does

This tool converts identifiers, one per line, between snake_case, camelCase, PascalCase, kebab-case and CONSTANT_CASE, in any direction. It also reports which style your input looked like, so a mixed list is easy to spot. It is built for the practical job of mapping database columns to code properties, API fields to variables, or config keys to environment variables.

When you need it

  • Mapping snake_case database columns or Python and Ruby field names to camelCase in JavaScript, Java or JSON.
  • Going the other way when a front-end model has to match a snake_case API or ORM.
  • Producing kebab-case for CSS classes, file names and URL segments, PascalCase for class and type names, or CONSTANT_CASE for environment variables.
  • Cleaning up a list where the original naming is inconsistent.

The rules, exactly

Each line is converted on its own. Indentation is kept. Within a line, the text is split into words and rejoined in the target style.

Where words split. At any character that is not a letter or a digit, so spaces, underscores, hyphens and dots all count as separators. Also inside a run of letters: between a lowercase letter or digit and a following capital (userId is user, Id), and at the end of a capital run just before a capital-plus-lowercase pair (HTTPServer is HTTP, Server; parseXMLDocument is parse, XML, Document).

Acronyms. They split correctly but are not kept capitalized in the output. All words are lowercased, then capitalized where the style needs it, so userID is user_id in snake_case and userId in camelCase. This matches the convention in Google's Java style guide and most linters. A consequence is that the conversion is not perfectly reversible: user_ID to camelCase and back gives user_id.

Leading and trailing underscores. They are preserved. _internal_cache becomes _internalCache in camelCase, __init__ is unchanged in snake_case, and class_ stays class_. These underscores carry meaning (private names, dunder methods, keyword escapes), so the tool does not treat them as separators.

Digits. By default a digit stays with the letters before it, so sha256Hash is sha256_hash and ipv4Address is ipv4_address. A capital after a digit starts a new word: v2Beta is v2_beta. The split-digits option instead puts each digit run in its own word, giving sha_256_hash, v_2_beta and oauth-2-token. Style guides and code generators disagree on this, so pick the behavior your target system expects.

Known quirks. A lowercase letter followed by a capital always starts a word, so iOS becomes i_os and H2O becomes h2_o. If a name contains such cases, check the result by hand. Characters from non-Latin alphabets are treated as letters; scripts without case, such as Japanese, never trigger a case boundary.

Detected style

The "Detected input style(s)" output lists each distinct style seen across your lines: snake_case, CONSTANT_CASE, kebab-case, camelCase, PascalCase, single words, or "mixed or phrase" for lines containing spaces. It is a guide for catching inconsistent input, not a validator. A single capitalized word such as Config is reported as PascalCase because it is indistinguishable from one.

Examples of the same name in every style

getHTTPResponseCode converts to get_http_response_code (snake), getHttpResponseCode (camel), GetHttpResponseCode (Pascal), get-http-response-code (kebab) and GET_HTTP_RESPONSE_CODE (constant).

Limits

Input is capped at 100,000 characters. The tool converts names; it does not rename them in your source code, update references, or check for collisions where two different names map to the same result, such as user_id and userId both becoming userId.

Frequently asked questions

How is HTTPServer converted to snake_case?
To http_server. The splitter breaks a run of capitals just before a capital that is followed by a lowercase letter, so HTTPServer is HTTP and Server. The same rule makes parseXMLDocument into parse_xml_document and userID into user_id.
Are leading and trailing underscores kept?
Yes. _privateValue becomes _private_value in snake_case, and __init__ stays __init__, because those underscores are a naming convention (private names, dunder methods, reserved-word escapes like class_) rather than word separators. Underscores in the middle are separators and are removed or converted.
What happens to digits?
By default digits stay with the letters before them: sha256Hash becomes sha256_hash and ipv4Address becomes ipv4_address. A capital after a digit starts a new word (v2Beta becomes v2_beta). Tick the split-digits option to put every digit run in its own word, which gives sha_256_hash. Style guides differ here, so pick the one your codebase uses.
Is it a round trip? Does snake to camel and back give the original?
Not always. Acronyms are lowercased in camelCase (user_ID becomes userId), so converting back gives user_id, and mixed styles in the same name are normalized. For plain lowercase words it does round trip, as long as digit handling is set the same way in both directions.