PyStringToolkit is a lightweight and intuitive Python library offering a rich set of utilities for string manipulation and transformation. Whether you're building web applications, preprocessing text for machine learning, or just want cleaner and more readable code — this toolkit simplifies the process with clean and reusable functions.
Transform strings between common naming conventions:
to_snake_case()→ Converts text tosnake_caseto_camel_case()→ Converts text tocamelCaseto_pascal_case()→ Converts text toPascalCaseto_kebab_case()→ Converts text tokebab-caseto_upper_case()→ Converts all letters to uppercaseto_lower_case()→ Converts all letters to lowercaseto_title_case()→ Capitalizes the first letter of each wordto_alternating_case()→ alternates uppercase and lowercase characters in a string
Remove unwanted characters and normalize formatting:
remove_punctuation()→ Strips punctuation, preserving only letters and digitsremove_whitespaces()→ Removes all whitespaces from the stringremove_extra_spaces()→ Reduces multiple spaces to a single spacetruncate(length)→ Cuts off text after a specified length, adding ellipsiscontains_only_alpha()→ Checks if the string contains only alphabetic charactersstrip_html_tags()-> remove any HTML tags in a string
Helpful tools for generating and formatting text:
slugify()→ Converts text into URL-friendly slugs ("Hello World!" → "hello-world")random_string(length)→ Generates a random alphanumeric string of a given length
is_email()→ function validates if a string is a properly formatted email address
Install the latest version via pip:
pip install pystringtoolkitfrom pystringtoolkit import to_snake_case
print(to_snake_case("Hello World!")) # hello_worldYou can find the contribution guide here to contribute in this project. Contribution Guide Thanks
Full documentation is available here 👉 PyStringToolkit Docs
The docs include:
- Installation guide
- Usage patterns & best practices
We value our contributors!
All the people who help improve PyStringToolkit are listed in CONTRIBUTORS.md.
A huge thanks to everyone — whether it’s code, docs, tests, or ideas 🙌