convert-caseRust 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.
This is list of cases that convert_case provides out of the box. You can always make your own custom case.
| Case | Example |
|---|---|
| Snake | my_variable_name |
| Constant UpperSnake | MY_VARIABLE_NAME |
| Ada | My_Variable_Name |
| Kebab | my-variable-name |
| Cobol UpperKebab | MY-VARIABLE-NAME |
| Train | My-Variable-Name |
| Flat | myvariablename |
| UpperFlat | MYVARIABLENAME |
| Pascal UpperCamel | MyVariableName |
| Camel | myVariableName |
| Upper | MY VARIABLE NAME |
| Lower | my variable name |
| Title | My Variable Name |
| Sentence | My variable name |
convert_case_extrasSome 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.
ccaseThe 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_case | convert_case_extras | ccase | |
|---|---|---|---|
| Repository | github | github | github |
| Crate | crates.io | crates.io | crates.io |
| Documentation | docs.rs | docs.rs |
This release improves speed and memory efficiency. A couple techniques were used:
split method.split. Built-in boundaries get a custom implementation built on top of this bitmask.| Benchmark | Before | After | Improvement |
|---|---|---|---|
snake_short ("hello_world") | 412 ns | 21.3 ns | −95% |
lower_upper ("lowerUpperUpper") | 1,631 ns | 475 ns | −71% |
acronym ("XMLRequest") | 1,108 ns | 418 ns | −62% |
camel_set ("getTotalLength3D") | 3,844 ns | 643 ns | −83% |
defaults_mixed (9 boundaries) | 8,083 ns | 1,500 ns | −81% |
defaults_long_snake (265 chars) | 52,281 ns | 4,730 ns | −91% |
unicode_cyrillic ("ПЕРСПЕКТИВА24") | 8,334 ns | 741 ns | −91% |
Full pipeline from_to_all (4 words x 14 x 14) | 1,230 µs | 263 µs | −79% |
See CHANGELOG.md for the full history.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
487 followers · starred Mar 2022
425 followers · starred Aug 2023
713 followers · starred Dec 2024
165 followers · starred Aug 2026
convert-caseRust 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.
This is list of cases that convert_case provides out of the box. You can always make your own custom case.
| Case | Example |
|---|---|
| Snake | my_variable_name |
| Constant UpperSnake | MY_VARIABLE_NAME |
| Ada | My_Variable_Name |
| Kebab | my-variable-name |
| Cobol UpperKebab | MY-VARIABLE-NAME |
| Train | My-Variable-Name |
| Flat | myvariablename |
| UpperFlat | MYVARIABLENAME |
| Pascal UpperCamel | MyVariableName |
| Camel | myVariableName |
| Upper | MY VARIABLE NAME |
| Lower | my variable name |
| Title | My Variable Name |
| Sentence | My variable name |
convert_case_extrasSome 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.
ccaseThe 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_case | convert_case_extras | ccase | |
|---|---|---|---|
| Repository | github | github | github |
| Crate | crates.io | crates.io | crates.io |
| Documentation | docs.rs | docs.rs |
This release improves speed and memory efficiency. A couple techniques were used:
split method.split. Built-in boundaries get a custom implementation built on top of this bitmask.| Benchmark | Before | After | Improvement |
|---|---|---|---|
snake_short ("hello_world") | 412 ns | 21.3 ns | −95% |
lower_upper ("lowerUpperUpper") | 1,631 ns | 475 ns | −71% |
acronym ("XMLRequest") | 1,108 ns | 418 ns | −62% |
camel_set ("getTotalLength3D") | 3,844 ns | 643 ns | −83% |
defaults_mixed (9 boundaries) | 8,083 ns | 1,500 ns | −81% |
defaults_long_snake (265 chars) | 52,281 ns | 4,730 ns | −91% |
unicode_cyrillic ("ПЕРСПЕКТИВА24") | 8,334 ns | 741 ns | −91% |
Full pipeline from_to_all (4 words x 14 x 14) | 1,230 µs | 263 µs | −79% |
See CHANGELOG.md for the full history.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
487 followers · starred Mar 2022
425 followers · starred Aug 2023
713 followers · starred Dec 2024
165 followers · starred Aug 2026