textcase

0.4.5 · active · verified Thu Apr 16

textcase is a lightweight, performant Python library designed for comprehensive text case conversions. It supports a wide array of cases like snake_case, kebab-case, and camelCase, and handles complex word boundaries including acronyms and non-ASCII characters. The library is notable for having zero external dependencies and a strong focus on accuracy and extensibility. It is actively maintained with frequent releases, with the current version 0.4.5, released in October 2025, ensuring Python 3.14 compatibility.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `textcase` library and use its direct methods to convert strings between common text cases like snake_case, camelCase, kebab-case, and PascalCase. It also shows how to use the `.match()` method to check if a string conforms to a specific case.

import textcase

input_string = "Hello, beautiful_World! How are you in this wonderful-Day?"

# Convert to snake_case
snake_case_string = textcase.snake(input_string)
print(f"Snake Case: {snake_case_string}")

# Convert to camelCase
camel_case_string = textcase.camel(input_string)
print(f"Camel Case: {camel_case_string}")

# Convert to KEBAB-CASE
kebab_case_string = textcase.kebab(input_string)
print(f"Kebab Case: {kebab_case_string}")

# Convert to PascalCase
pascal_case_string = textcase.pascal(input_string)
print(f"Pascal Case: {pascal_case_string}")

# Check if a string matches a specific case
is_kebab = textcase.kebab.match("my-css-class")
print(f"'my-css-class' is Kebab Case: {is_kebab}")

is_snake = textcase.snake.match("my_css_class")
print(f"'my_css_class' is Snake Case: {is_snake}")

view raw JSON →