Skip to content
uencoder
TUTORIAL

How to Convert Text Case

Transform text between camelCase, snake_case, kebab-case, PascalCase, and more.

Problem

You have text in one naming convention and need it in another for a different programming language or style guide.

Prerequisites

  • Understanding of naming conventions
  • Familiarity with word boundaries

Steps

  1. 1. Identify the source convention

    Determine the current case: camelCase (lowercase first, capitals at word boundaries), snake_case (underscores), kebab-case (hyphens), PascalCase (capital first), or SCREAMING_SNAKE. Detecting the source convention correctly is essential for accurate conversion.

    Input
    camelCase: myVariableName
    Output
    convention identified
  2. 2. Split into words

    Parse the text into individual words by detecting boundaries: underscores, hyphens, capital letters (for camelCase/PascalCase), or spaces. Handle consecutive capitals carefully (e.g., 'HTTPServer' → 'HTTP' + 'Server').

    Input
    myVariableName
    Output
    words: [my, Variable, Name]
  3. 3. Rejoin in the target convention

    Combine the words using the target convention's separator and capitalization. For snake_case, join with underscores in lowercase. For camelCase, lowercase the first word and capitalize the rest. For kebab-case, join with hyphens in lowercase.

    Input
    words + target: snake_case
    Output
    my_variable_name

Expected result

Text correctly converted to the target naming convention.

Common errors

Consecutive capitals split incorrectly
Words like 'XMLParser' should split into 'XML' and 'Parser', not 'X', 'M', 'L', 'Parser'. Use a converter that handles consecutive capitals intelligently.
Acronyms lowercased incorrectly
Some conventions preserve acronyms (e.g., 'parseXML' not 'parseXml'). Check your converter's acronym handling.

Troubleshooting

  • If the output looks wrong, check how the source was split into words.
  • Test with edge cases like single words, all-caps, and mixed separators.

Security limits

  • Case conversion is a pure text transformation with no security implications.

Related tools

Related tasks

Ready to run it?

References