Search by

jawira / case-converter

jawira

Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.

Package info

github.com/jawira/case-converter

Homepage

pkg:composer/jawira/case-converter

Statistics

Installs: 8 987 682

Dependents: 85

Suggesters: 4

Stars: 174

Open Issues: 1

v3.7.0 2026-10-12 17:46 UTC

README

Use this library to convert strings between the following cases:

Name Method Output example
🐪 Camel case toCamel() myNameIsBond
👨‍🏫 Pascal case toPascal() MyNameIsBond
🐍 Snake case toSnake() my_name_is_bond
👩‍🏫 Ada case toAda() My_Name_Is_Bond
Ⓜ️ Macro case toMacro() MY_NAME_IS_BOND
🥙 Kebab case toKebab() my-name-is-bond
🚂 Train case toTrain() My-Name-Is-Bond
🏦 Cobol case toCobol() MY-NAME-IS-BOND
🔡 Lower case toLower() my name is bond
🔠 Upper case toUpper() MY NAME IS BOND
📰 Title case toTitle() My Name Is Bond
✍️ Sentence case toSentence() My name is bond
⚙️ Dot notation toDot() my.name.is.bond

Features:

Total Downloads PHP Version Require Latest Stable Version License

Usage

The input string's format is detected automatically.

For example:

use Jawira\CaseConverter\Convert;

$hero = new Convert('john-connor');

echo $hero->toCamel();   // output: johnConnor

You can also specify the input string's format explicitly:

echo $hero->fromKebab()->toSnake();   // output: john_connor

You can also use the provided factory to create a Convert instance. See the list of all public methods for more options.

i18n

The library supports non-English alphabets:

// Spanish
$esp = new Convert('DON_RAMÓN_Y_ÑOÑO');
echo $esp->toCamel();   // output: donRamónYÑoño

// Greek
$grc = new Convert('πολύ-Καλό');
echo $grc->toCamel();   // output: πολύΚαλό

// Russian
$rus = new Convert('ОЧЕНЬ_ПРИЯТНО');
echo $rus->toCamel();   // output: оченьПриятно

case-converter supports both Simple Case-Mapping and Full Case-Mapping. Learn more about Case-Mapping.

Installation

composer require jawira/case-converter

Documentation

https://jawira.github.io/case-converter/

Contributing

  • If you liked this project, ⭐ star it on GitHub. GitHub Repo stars
  • Or follow me on X. Twitter Follow

License

This library is licensed under the MIT LICENSE.

Packages from jawira

jawira/emoji-catalog GitHub stars
Get access to +3000 emojis as class constants.
jawira/plantuml-client GitHub stars
Convert PlantUML diagrams into images (svg, png, ...).
jawira/doctrine-diagram-bundle GitHub stars
Symfony Bundle to generate database diagrams.
more...