rutrum/convert-case

Converts to and from various cases.

Rust

169

94 commits

updated Aug 27, 2026

See the code

README

convert-case

Rust library for converting between string cases.

use convert_case::ccase;

assert_eq!(
    ccase!(camel, "My_Var_Name"),
    "myVarName",
);
assert_eq!(
    ccase!(snake, "IOStream"),
    "io_stream",
);
assert_eq!(
    ccase!(snake -> title, "2020-04-16_family_photo"),
    "2020-04-16 Family Photo",
);

convert-case is highly customizable. You can read the API documentation on docs.rs for a list of all features and read lots of examples.

Cases

This is list of cases that convert_case provides out of the box. You can always make your own custom case.

CaseExample
Snakemy_variable_name
Constant
UpperSnake
MY_VARIABLE_NAME
AdaMy_Variable_Name
Kebabmy-variable-name
Cobol
UpperKebab
MY-VARIABLE-NAME
TrainMy-Variable-Name
Flatmyvariablename
UpperFlatMYVARIABLENAME
Pascal
UpperCamel
MyVariableName
CamelmyVariableName
UpperMY VARIABLE NAME
Lowermy variable name
TitleMy Variable Name
SentenceMy variable name

Additional utilities with convert_case_extras

Some cases and utilities that didn't feel appropriate in this library are made available in a distinct crate called convert_case_extras. This crate is a demonstration of what can be built on top of the convert_case API.

Command Line Utility ccase

The command line utility ccase was made to expose the tools of the convert_case library to the command line.

$ ccase -t title super_mario_64
Super Mario 64

$ ccase -f snake -t title 2020-04-15_my_cat
2020-04-16 My Cat

$ ccase -t camel "convert to camel"
convertToCamel
convert_caseconvert_case_extrasccase
Repositorygithubgithubgithub
Cratecrates.iocrates.iocrates.io
Documentationdocs.rsdocs.rs

Change Log

0.12.0: Optimizations

This release improves speed and memory efficiency. A couple techniques were used:

  • Character case checks first check ascii before doing the more expensive grapheme checks (which require heap allocations).
  • Delimiter only splits get a dedicated path in the split method.
  • The case of characters is computed upfront in a bitmask before checking individual boundary conditions in split. Built-in boundaries get a custom implementation built on top of this bitmask.
BenchmarkBeforeAfterImprovement
snake_short ("hello_world")412 ns21.3 ns−95%
lower_upper ("lowerUpperUpper")1,631 ns475 ns−71%
acronym ("XMLRequest")1,108 ns418 ns−62%
camel_set ("getTotalLength3D")3,844 ns643 ns−83%
defaults_mixed (9 boundaries)8,083 ns1,500 ns−81%
defaults_long_snake (265 chars)52,281 ns4,730 ns−91%
unicode_cyrillic ("ПЕРСПЕКТИВА24")8,334 ns741 ns−91%
Full pipeline from_to_all (4 words x 14 x 14)1,230 µs263 µs−79%

See CHANGELOG.md for the full history.

case
case-converter
rust

rutrum/convert-case

Converts to and from various cases.

Rust

169

94 commits

updated Aug 27, 2026

See the code

README

convert-case

Rust library for converting between string cases.

use convert_case::ccase;

assert_eq!(
    ccase!(camel, "My_Var_Name"),
    "myVarName",
);
assert_eq!(
    ccase!(snake, "IOStream"),
    "io_stream",
);
assert_eq!(
    ccase!(snake -> title, "2020-04-16_family_photo"),
    "2020-04-16 Family Photo",
);

convert-case is highly customizable. You can read the API documentation on docs.rs for a list of all features and read lots of examples.

Cases

This is list of cases that convert_case provides out of the box. You can always make your own custom case.

CaseExample
Snakemy_variable_name
Constant
UpperSnake
MY_VARIABLE_NAME
AdaMy_Variable_Name
Kebabmy-variable-name
Cobol
UpperKebab
MY-VARIABLE-NAME
TrainMy-Variable-Name
Flatmyvariablename
UpperFlatMYVARIABLENAME
Pascal
UpperCamel
MyVariableName
CamelmyVariableName
UpperMY VARIABLE NAME
Lowermy variable name
TitleMy Variable Name
SentenceMy variable name

Additional utilities with convert_case_extras

Some cases and utilities that didn't feel appropriate in this library are made available in a distinct crate called convert_case_extras. This crate is a demonstration of what can be built on top of the convert_case API.

Command Line Utility ccase

The command line utility ccase was made to expose the tools of the convert_case library to the command line.

$ ccase -t title super_mario_64
Super Mario 64

$ ccase -f snake -t title 2020-04-15_my_cat
2020-04-16 My Cat

$ ccase -t camel "convert to camel"
convertToCamel
convert_caseconvert_case_extrasccase
Repositorygithubgithubgithub
Cratecrates.iocrates.iocrates.io
Documentationdocs.rsdocs.rs

Change Log

0.12.0: Optimizations

This release improves speed and memory efficiency. A couple techniques were used:

  • Character case checks first check ascii before doing the more expensive grapheme checks (which require heap allocations).
  • Delimiter only splits get a dedicated path in the split method.
  • The case of characters is computed upfront in a bitmask before checking individual boundary conditions in split. Built-in boundaries get a custom implementation built on top of this bitmask.
BenchmarkBeforeAfterImprovement
snake_short ("hello_world")412 ns21.3 ns−95%
lower_upper ("lowerUpperUpper")1,631 ns475 ns−71%
acronym ("XMLRequest")1,108 ns418 ns−62%
camel_set ("getTotalLength3D")3,844 ns643 ns−83%
defaults_mixed (9 boundaries)8,083 ns1,500 ns−81%
defaults_long_snake (265 chars)52,281 ns4,730 ns−91%
unicode_cyrillic ("ПЕРСПЕКТИВА24")8,334 ns741 ns−91%
Full pipeline from_to_all (4 words x 14 x 14)1,230 µs263 µs−79%

See CHANGELOG.md for the full history.

case
case-converter
rust

Project health

Overall

3.5/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

crates.io

Latest release

0.12.0 · Aug 27, 2026

Releases this year

4

Significant stargazers

waffle

487 followers · starred Mar 2022

Joseph T. Lyons

425 followers · starred Aug 2023

Clément Renault

713 followers · starred Dec 2024

Dion Dokter

165 followers · starred Aug 2026