Registry / serialization / textcase

textcase

JSON →
library0.4.5pypypi✓ verified 86d ago

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.

pip install textcase
INSTALL
IMPORT
SIG · TEXTCASE
T
textcase
serializationpythonv0.4.5
Install
1.7s avg
Import
41ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.043s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.7s · import 0.040s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

textcase
import textcase
from textcase import case, convert
The `case` and `convert` functions were part of an older API (pre-0.4.0) and are no longer the primary way to interact with the library. Direct methods on the `textcase` module are now used.

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}")
Debug
Known issues
breakingVersion 0.4.0 introduced a significant rewrite of the library's internal structure and API. The primary way to import and use the library changed from `from textcase import case, convert` to directly importing `textcase` and calling methods on the module (e.g., `textcase.snake()`).
fix
Update your imports from `from textcase import case, convert` to `import textcase` and adjust calls from `convert(string, case.SNAKE)` to `textcase.snake(string)`.
affects: 0.4.0 and later
gotchaThe library primarily focuses on case conversion based on defined word boundaries. For languages or specific contexts requiring Unicode normalization (e.g., decomposing accented characters before processing), `textcase` does not perform this automatically. Users should handle Unicode normalization separately if needed.
fix
If Unicode normalization is required for your text, preprocess strings using Python's `unicodedata` module (e.g., `unicodedata.normalize('NFKC', my_string)`) before passing them to `textcase` functions.
affects: All versions
gotchaBehavior around stripping leading/trailing punctuation and handling specific delimiters was refined in versions 0.4.2 and 0.4.4. If you rely on very specific edge-case punctuation handling, test thoroughly after updating, as outputs might have subtly changed due to bug fixes and optimizations.
fix
Review the release notes for versions 0.4.2 and 0.4.4 for details on punctuation stripping changes. Ensure your tests cover expected punctuation behavior, especially for edge cases.
affects: Pre-0.4.2
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'textcase'
The 'textcase' library is not installed in the current Python environment.
fix
Run `pip install textcase` to install the library.
AttributeError: module 'textcase' has no attribute 'convert'
You are attempting to use the `convert` function, which was part of an older API (pre-0.4.0 rewrite). The current API uses direct methods on the `textcase` module.
fix
Update your code to use the new API. For example, replace `convert(my_string, case.SNAKE)` with `textcase.snake(my_string)`.
TypeError: 'Case' object is not callable
This error can occur if you're trying to call `textcase.case.SNAKE()` as a function, or if you're attempting to access `case` or `convert` from an outdated import pattern after the 0.4.0 rewrite.
fix
Ensure you are using `import textcase` and calling methods directly on the module, e.g., `textcase.snake("my string")`. The `case` object is no longer directly exposed in the same way for conversion functions.
Upgrade
Version history
0.4.5latest on PyPI · released Oct 10, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
textcase — pip install textcase · libregistry