One name, five spellings.
Turn names into camelCase, snake_case, kebab-case, CONSTANT_CASE or URL slugs in your browser, line by line, with nothing uploaded.
By Suraj Kumar4 min read
The same field is userId in the JavaScript, user_id in the database and user-id in the CSS. Rewriting a list of names by hand is slow and easy to get wrong; a converter does it the same way every time.
Which case goes where.
camelCase (myVariableName) is what JavaScript and Java use for variables and functions; Google's JavaScript style guide asks for it. snake_case (my_variable_name) is what Python's style guide, PEP 8, asks for in function and variable names, and it is common in databases. kebab-case (my-variable-name) is used for CSS classes and in web addresses. CONSTANT_CASE (MY_VARIABLE_NAME) marks constants, as PEP 8 also says, and environment variables. A slug (my-page-title) is kebab-case made safe for an address.
Convert a list of names.
Open the case converter, paste the names one a line, and under More options choose camelCase, snake_case, kebab-case, CONSTANT_CASE or Slug. Each line is converted on its own, so a column of field names stays a column, and empty lines stay empty.
user ID userId user_id user-id
XMLHttpRequest xmlHttpRequest xml_http_request xml-http-request
first-name firstName first_name first-nameHow the words are found.
Names are split into words at spaces and punctuation, and where a small letter meets a capital, so firstName is first and Name. A run of capitals followed by a capital and a small letter is split before the last capital, so XMLHttpRequest becomes XML, Http and Request, and the abbreviation is then written like any other word: xmlHttpRequest. Digits stay with the letters before them, so parseHTML5Page becomes parseHtml5Page.
PascalCase, with the first word capitalised too, is not one of the choices.
Slugs for addresses.
Slug writes each line as a lower-case part of an address with the slugify library: accents are taken off, & becomes and, and other symbols are spelt out or dropped. Crème Brûlée & Café! becomes creme-brulee-and-cafe, and I ♥ Dogs becomes i-love-dogs.
For sentences, the other cases.
For headings and text rather than names, the same tool changes text to Sentence case, to Title Case in AP, APA, Chicago or MLA style, or to UPPER or lower case, keeping names like iPhone and NASA as they are written. Every change is one step you can undo, and nothing is uploaded.
Further reading
Topics: camelcase converter · snake case converter · kebab case converter · camel case to snake case · constant case · slug generator · variable name converter
A little less theory. A little more doing.
Try it on your own terms, with a free browser tool.
Try the tool