Case Converter

Convert identifiers between camelCase, snake_case, kebab-case, and more

Runs in your browserUtility05Text & Diff

What is Case Converter?

A case converter rewrites an identifier between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, and other naming styles, and it handles a whole list line by line. The conversion runs inside the browser, which makes it handy for migrating field names and generating constants.

How to use Case Converter

  1. 1Enter one identifier per line; pasting a whole batch works fine.
  2. 2The tool produces the result in every target style at once.
  3. 3Copy the column you need straight into your code.
  4. 4Review the word splitting by hand for identifiers that contain digits or acronyms.

How do I do this in code?

Use the tool above for one-off work; for anything you repeat, move it into a script or your project.

const words = (input) =>
  input
    .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
    .split(/[\s_-]+/)
    .filter(Boolean)
    .map((w) => w.toLowerCase());

const toCamel = (s) =>
  words(s)
    .map((w, i) => (i ? w[0].toUpperCase() + w.slice(1) : w))
    .join('');

Frequently asked questions

How are runs of capitals like HTTPRequest handled?+

A run of capital letters is treated as a single word, so HTTPRequest becomes http_request rather than h_t_t_p_request. Acronyms mixed with digits, such as OAuth2Token, are genuinely ambiguous to split, so it is worth checking those results by hand.

Why do database columns use snake_case while code uses camelCase?+

It is convention on each side. Most SQL databases are case-insensitive or fold identifiers to one case, which makes underscores the safer separator, while the Java and JavaScript ecosystems name variables in camelCase. An ORM or serialization layer normally maps between the two.

Related tools

All tools