Skip to main content

String case style converter (snake_case, camelCase, PascalCase, kebab-case, MACRO_CASE can be converted to each other).

  • Functions:
    • casestyle.camelcase(string)

    • casestyle.pascalcase(string)

    • casestyle.snakecase(string)

    • casestyle.kebabcase(string)

    • casestyle.macrocase(string)

    • casestyle.casepreprocess(string)

  • Other Useful Python String Methods:
    • str.title()

    • str.capitalize()

    • str.lower()

    • str.upper()

    • str.swapcase()

Installation

You can install “casestyle” via pip from PyPI:

$ pip install casestyle

Usage

import casestyle
casestyle.camelcase('foo bar baz') # => "fooBarBaz"
casestyle.camelcase('fooBarBaz') # => "fooBarBaz"
casestyle.camelcase('FooBarBaz') # => "fooBarBaz"
casestyle.camelcase('foo_bar_baz') # => "fooBarBaz"
casestyle.camelcase('foo-bar-baz') # => "fooBarBaz"
casestyle.camelcase('FOO_BAR_BAZ') # => "fooBarBaz"
casestyle.camelcase('foo _Bar___BAZ---Qux   quux') # => "fooBarBazQuxQuux"
casestyle.camelcase('_foo_bar') # => "_fooBar"
casestyle.camelcase('__foo_bar__') # => "__fooBar__"
casestyle.camelcase('$foo_bar') # => "$fooBar"

casestyle.pascalcase('foo bar baz') # => "FooBarBaz"
casestyle.pascalcase('fooBarBaz') # => "FooBarBaz"
casestyle.pascalcase('FooBarBaz') # => "FooBarBaz"
casestyle.pascalcase('foo_bar_baz') # => "FooBarBaz"
casestyle.pascalcase('foo-bar-baz') # => "FooBarBaz"
casestyle.pascalcase('FOO_BAR_BAZ') # => "FooBarBaz"
casestyle.pascalcase('foo _Bar___BAZ---Qux   quux') # => "FooBarBazQuxQuux"
casestyle.pascalcase('_foo_bar') # => "_FooBar"
casestyle.pascalcase('__foo_bar__') # => "__FooBar__"
casestyle.pascalcase('$foo_bar') # => "$FooBar"

casestyle.snakecase('foo bar baz') # => "foo_bar_baz"
casestyle.snakecase('fooBarBaz') # => "foo_bar_baz"
casestyle.snakecase('FooBarBaz') # => "foo_bar_baz"
casestyle.snakecase('foo_bar_baz') # => "foo_bar_baz"
casestyle.snakecase('foo-bar-baz') # => "foo_bar_baz"
casestyle.snakecase('FOO_BAR_BAZ') # => "foo_bar_baz"
casestyle.snakecase('foo _Bar___BAZ---Qux   quux') # => "foo_bar_baz_qux_quux"
casestyle.snakecase('_foo_bar') # => "_foo_bar"
casestyle.snakecase('__foo_bar__') # => "__foo_bar__"
casestyle.snakecase('$foo_bar') # => "$foo_bar"

casestyle.kebabcase('foo bar baz') # => "foo-bar-baz"
casestyle.kebabcase('fooBarBaz') # => "foo-bar-baz"
casestyle.kebabcase('FooBarBaz') # => "foo-bar-baz"
casestyle.kebabcase('foo_bar_baz') # => "foo-bar-baz"
casestyle.kebabcase('foo-bar-baz') # => "foo-bar-baz"
casestyle.kebabcase('FOO_BAR_BAZ') # => "foo-bar-baz"
casestyle.kebabcase('foo _Bar___BAZ---Qux   quux') # => "foo-bar-baz-qux-quux"
casestyle.kebabcase('_foo_bar') # => "_foo-bar"
casestyle.kebabcase('__foo_bar__') # => "__foo-bar__"
casestyle.kebabcase('$foo_bar') # => "$foo-bar"

casestyle.macrocase('foo bar baz') # => "FOO_BAR_BAZ"
casestyle.macrocase('fooBarBaz') # => "FOO_BAR_BAZ"
casestyle.macrocase('FooBarBaz') # => "FOO_BAR_BAZ"
casestyle.macrocase('foo_bar_baz') # => "FOO_BAR_BAZ"
casestyle.macrocase('foo-bar-baz') # => "FOO_BAR_BAZ"
casestyle.macrocase('FOO_BAR_BAZ') # => "FOO_BAR_BAZ"
casestyle.macrocase('foo _Bar___BAZ---Qux   quux') # => "FOO_BAR_BAZ_QUX_QUUX"
casestyle.macrocase('_foo_bar') # => "_FOO_BAR"
casestyle.macrocase('__foo_bar__') # => "__FOO_BAR__"
casestyle.macrocase('$foo_bar') # => "$FOO_BAR"

Metadata

Release files for casestyle 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for casestyle 0.0.4
File Size Uploaded Provenance Actions
casestyle-0.0.4.tar.gz 2.8 kB Without provenance Details for casestyle-0.0.4.tar.gz

Release files / casestyle-0.0.4.tar.gz

Download URL casestyle-0.0.4.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a4291b396ce5b5ff51d44f0917226a12734a360cec8704a82c78653ff85b0c99
BLAKE2b-256 checksum
How to use checksums
af5daef2ccba6651d643158f64086891966d50f734e45dc9f9b4192056898e20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5

Security for casestyle 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page