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 2 months 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 (11 months ago)
- Default Branch: main
- Last Pushed: 2025-04-08T17:30:06.000Z (11 months ago)
- Last Synced: 2025-04-08T18:33:34.590Z (11 months 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
Python library for text case conversions.
**Documentation**: https://zobweyt.github.io/textcase
**PyPI**: https://pypi.org/project/textcase
## Features
- **Text case conversion**: [convert](https://zobweyt.github.io/textcase/#usage) strings between various text cases (e.g., [snake_case](https://zobweyt.github.io/textcase/reference/#textcase.snake), [kebab-case](https://zobweyt.github.io/textcase/reference/#textcase.kebab), [camelCase](https://zobweyt.github.io/textcase/reference/#textcase.camel), etc.).
- **Extensible**: extend the library with custom word [boundaries](https://zobweyt.github.io/textcase/learn/boundaries) and [cases](https://zobweyt.github.io/textcase/learn/cases).
- **Accurate**: [handles any word boundaries](https://zobweyt.github.io/textcase/#precision) in strings including [acronyms](https://zobweyt.github.io/textcase/reference/#textcase.ACRONYM) (as in `"HTTPRequest"`).
- **Non-ASCII Support**: handles [non-ASCII characters](https://zobweyt.github.io/textcase/#non-ascii-characters) seamlessly (no inferences on the input language itself is made).
- **Tiny, Performant & Zero Dependencies**: a regex-free, efficient library that stays lightweight with no external dependencies.
- **100% test coverage**: every line of code is rigorously tested for reliability.
- **100% type annotated codebase**: full type annotations for best developer experience.
## Installation
Create and activate a virtual environment and then install [`textcase`](https://pypi.org/projects/textcase):
```sh
pip install textcase
```
## Usage
Convert a string to a text case:
```python
import textcase
textcase.snake("Hello, world!") # hello_world
textcase.constant("Hello, world!") # HELLO_WORLD
textcase.kebab("Hello, world!") # hello-world
textcase.middot("Hello, world!") # hello·world
textcase.camel("Hello, world!") # helloWorld
textcase.pascal("Hello, world!") # HelloWorld
textcase.lower("Hello, world!") # hello world
textcase.upper("Hello, world!") # HELLO WORLD
textcase.title("Hello, world!") # Hello World
textcase.sentence("Hello, world!") # Hello world
```
See [documentation](https://zobweyt.github.io/textcase) for more usage examples.