Casefy
Casefy is a lightweight Python package for converting the casing of strings. It supports various case styles like snake_case, camelCase, PascalCase, kebab-case, and more, including Unicode characters. The library has no third-party dependencies. It is currently at version 1.1.0 and receives updates as needed for bug fixes or new features.
Warnings
- breaking The behavior of the `keep_together` parameter in `snakecase` and `separatorcase` functions was updated in version 1.1.0. If you were relying on specific word grouping behavior with this parameter, review your usage.
- gotcha Casefy was created as a spiritual successor to the `python-stringcase` library. While the API was kept similar to facilitate migration, users migrating from `python-stringcase` should verify full compatibility as subtle differences may exist.
Install
-
pip install casefy
Imports
- casefy
import casefy
Quickstart
import casefy
# Convert a string to snake_case
text = "HelloWorldExample123"
snake_cased_text = casefy.snakecase(text)
print(f"Original: {text}\nSnake Case: {snake_cased_text}")
# Convert to camelCase
camel_cased_text = casefy.camelcase("another-example_string")
print(f"Camel Case: {camel_cased_text}")
# Convert to PascalCase with specific grouping
pascal_cased_text = casefy.pascalcase("foo_bar_baz", keep_together=["BAR"])
print(f"Pascal Case: {pascal_cased_text}")