https://github.com/zobweyt/textcase
A feature-rich Python text case conversion library
https://github.com/zobweyt/textcase
camel-case case constant-case conversion foss just kebab-case lower-case mypy nix pascal-case pypi pytest python ruff sentence-case snake-case text title-case upper-case
Last synced: about 1 month ago
JSON representation
A feature-rich Python text case conversion library
- Host: GitHub
- URL: https://github.com/zobweyt/textcase
- Owner: zobweyt
- License: gpl-3.0
- Created: 2025-03-31T18:51:23.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-04-08T17:30:06.000Z (about 1 month ago)
- Last Synced: 2025-04-08T18:33:34.590Z (about 1 month ago)
- Topics: camel-case, case, constant-case, conversion, foss, just, kebab-case, lower-case, mypy, nix, pascal-case, pypi, pytest, python, ruff, sentence-case, snake-case, text, title-case, upper-case
- Language: Python
- Homepage: https://zobweyt.github.io/textcase
- Size: 1.89 MB
- Stars: 168
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
textcase
A feature-rich Python text case conversion library.**Documentation**: https://zobweyt.github.io/textcase
**PyPI**: https://pypi.org/project/textcase
## Features
- **Text case conversion**: Convert strings between various text cases (e.g., snake_case, kebab-case, camelCase, etc.).
- **Extensible Design**: Easily extend the library with custom cases and boundaries.
- **Acronym Handling**: Properly detects and formats acronyms in strings (as in `HTTPRequest`).
- **Non-ASCII Support**: Handles non-ASCII characters seamlessly (no inferences on the input language itself is made).
- **100% Test Coverage**: Comprehensive tests ensure reliability and correctness.
- **Well-Documented**: Clean documentation with usage examples for easy understanding.
- **Performant**: Efficient implementation without the use of regular expressions.
- **Zero Dependencies**: The library has no external dependencies, making it lightweight and easy to integrate.## Installation
Create and activate a virtual environment and then install [`textcase`](https://pypi.org/projects/textcase):
```sh
pip install textcase
```## Usage
You can convert strings into a case using the [`convert`](https://zobweyt.github.io/textcase/reference/convert/) function:
```python
from textcase import case, convertprint(convert("ronnie james dio", case.SNAKE)) # ronnie_james_dio
print(convert("Ronnie_James_dio", case.CONSTANT)) # RONNIE_JAMES_DIO
print(convert("RONNIE_JAMES_DIO", case.KEBAB)) # ronnie-james-dio
print(convert("RONNIE-JAMES-DIO", case.CAMEL)) # ronnieJamesDio
print(convert("ronnie-james-dio", case.PASCAL)) # RonnieJamesDio
print(convert("RONNIE JAMES DIO", case.LOWER)) # ronnie james dio
print(convert("ronnie james dio", case.UPPER)) # RONNIE JAMES DIO
print(convert("ronnie-james-dio", case.TITLE)) # Ronnie James Dio
print(convert("ronnie james dio", case.SENTENCE)) # Ronnie james dio
```See [documentation](https://zobweyt.github.io/textcase) for more usage examples.