case-conversion


Namecase-conversion JSON
Version 3.0.2 PyPI version JSON
download
home_pageNone
SummaryConvert between different types of cases (unicode supported)
upload_time2025-08-27 23:37:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords camel case conversion convert kebab pascal snake spinal unicode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](https://github.com/AlejandroFrias/case-conversion/workflows/CI/badge.svg)
![](https://img.shields.io/pypi/pyversions/case_conversion)
![](https://img.shields.io/pypi/v/case_conversion)
![](https://github.com/AlejandroFrias/case-conversion/blob/gh-pages/coverage.svg?raw=true)

# Case Conversion

This is a port of the Sublime Text 3 plugin [CaseConversion](https://github.com/jdc0589/CaseConversion), by [Davis Clark](https://github.com/jdc0589), to a regular python package. I couldn't find any other python packages on PyPI at the time (Feb 2016) that could seamlessly convert from any case to any other case without having to specify from what type of case I was converting. This plugin worked really well, so I separated the (non-sublime) python parts of the plugin into this useful python package. I also added Unicode support via python's `unicodedata` and extended the interface some.

## Features

- Auto-detection of case *(no need to specify explicitly which case you are converting from!)*
- Acronym detection *(no funky splitting on every capital letter of an all caps acronym like `HTTPError`!)*
- Unicode supported (non-ASCII characters are first class citizens!)
- Dependency free!
- Supports Python 3.10+
- Every case conversion from/to you ever gonna need:
  - `camel` -> "camelCase"
  - `pascal` / `mixed` -> "PascalCase" / "MixedCase"
  - `snake` -> "snake_case"
  - `snake` / `kebab` / `spinal` / `slug` -> "dash-case" / "kebab-case" / "spinal-case" / "slug-case"
  - `const` / `screaming_snake` -> "CONST_CASE" / "SCREAMING_SNAKE_CASE"
  - `dot` -> "dot.case"
  - `separate_words` -> "separate words"
  - `slash` -> "slash/case"
  - `backslash` -> "backslash\case"
  - `ada` -> "Ada_Case"
  - `http_header` -> "Http-Header-Case"

## Usage


### Converter Class

Basic

```python
>>> from case_conversion import Converter
>>> converter = Converter()
>>> converter.camel("FOO_BAR_STRING")
'fooBarString'
```

Initialize text when needing to convert the same text to multiple different cases.
```python
>>> from case_conversion import Converter
>>> converter = Converter(text="FOO_BAR_STRING")
>>> converter.camel()
'fooBarString'
>>> converter.pascal()
'FooBarString'
```

Initialize custom acronyms
```python
>>> from case_conversion import Converter
>>> converter = Converter(acronyms=["BAR"])
>>> converter.camel("FOO_BAR_STRING")
'fooBARString'
```

### Convenience Functions

For backwards compatibility and convenience, all converters are available as top level functions. They are all shorthand for:

`Converter(text, acronyms).converter_function()`

```python
>>> import case_conversion
>>> case_conversion.dash("FOO_BAR_STRING")
'foo-bar-string'
```

Simple acronym detection comes included, by treating strings of capital letters as a single word instead of several single letter words.

Custom acronyms can be supplied when needing to separate them from each other.
```python
>>> import case_conversion
>>> case_conversion.snake("fooBADHTTPError")
'foo_badhttp_error'  # we wanted BAD and HTTP to be separate!
>>> case_conversion.snake("fooBarHTTPError", acronyms=['BAD', 'HTTP'])
'foo_bad_http_error'  # custom acronyms achieved!
```

Unicode is fully supported - even for acronyms.

```python
>>> import case_conversion
>>> case_conversion.const(u"fóó-bar-string")
FÓÓ_BAR_STRING
>>> case_conversion.snake("fooBarHÓÓPError", acronyms=['HÓÓP'])
'foo_bar_hóóp_error'
```



## Install

```
pip install case-conversion
```

## Contribute

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

This package is being developed with [uv](https://github.com/astral-sh/uv) (-> [docs](https://docs.astral.sh/uv/)).

CI will run tests and lint checks.
Locally you can run them with:
```bash
# runs tests with coverage
make test
# Runs linter (using ruff)
make lint
# Auto-fix linter errors (using ruff --fix)
make format
# run type check (using ty)
make tc
```



## Credits

Credit goes to [Davis Clark's](https://github.com/jdc0589) as the author of the original plugin and its contributors (Scott Bessler, Curtis Gibby, Matt Morrison). Thanks for their awesome work on making such a robust and awesome case converter.

Further thanks and credit to [@olsonpm](https://github.com/olsonpm) for making this package dependency-free and encouraging package maintenance and best practices.


## License

Using [MIT license](LICENSE.txt) with Davis Clark's Copyright

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "case-conversion",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Alejandro Frias <joker454@gmail.com>",
    "keywords": "camel, case, conversion, convert, kebab, pascal, snake, spinal, unicode",
    "author": null,
    "author_email": "Alejandro Frias <joker454@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/47/92/fea5d4f8f859d9fa7700644da7ad0da3e3e1daadab9230960b59240f853a/case_conversion-3.0.2.tar.gz",
    "platform": null,
    "description": "![](https://github.com/AlejandroFrias/case-conversion/workflows/CI/badge.svg)\n![](https://img.shields.io/pypi/pyversions/case_conversion)\n![](https://img.shields.io/pypi/v/case_conversion)\n![](https://github.com/AlejandroFrias/case-conversion/blob/gh-pages/coverage.svg?raw=true)\n\n# Case Conversion\n\nThis is a port of the Sublime Text 3 plugin [CaseConversion](https://github.com/jdc0589/CaseConversion), by [Davis Clark](https://github.com/jdc0589), to a regular python package. I couldn't find any other python packages on PyPI at the time (Feb 2016) that could seamlessly convert from any case to any other case without having to specify from what type of case I was converting. This plugin worked really well, so I separated the (non-sublime) python parts of the plugin into this useful python package. I also added Unicode support via python's `unicodedata` and extended the interface some.\n\n## Features\n\n- Auto-detection of case *(no need to specify explicitly which case you are converting from!)*\n- Acronym detection *(no funky splitting on every capital letter of an all caps acronym like `HTTPError`!)*\n- Unicode supported (non-ASCII characters are first class citizens!)\n- Dependency free!\n- Supports Python 3.10+\n- Every case conversion from/to you ever gonna need:\n  - `camel` -> \"camelCase\"\n  - `pascal` / `mixed` -> \"PascalCase\" / \"MixedCase\"\n  - `snake` -> \"snake_case\"\n  - `snake` / `kebab` / `spinal` / `slug` -> \"dash-case\" / \"kebab-case\" / \"spinal-case\" / \"slug-case\"\n  - `const` / `screaming_snake` -> \"CONST_CASE\" / \"SCREAMING_SNAKE_CASE\"\n  - `dot` -> \"dot.case\"\n  - `separate_words` -> \"separate words\"\n  - `slash` -> \"slash/case\"\n  - `backslash` -> \"backslash\\case\"\n  - `ada` -> \"Ada_Case\"\n  - `http_header` -> \"Http-Header-Case\"\n\n## Usage\n\n\n### Converter Class\n\nBasic\n\n```python\n>>> from case_conversion import Converter\n>>> converter = Converter()\n>>> converter.camel(\"FOO_BAR_STRING\")\n'fooBarString'\n```\n\nInitialize text when needing to convert the same text to multiple different cases.\n```python\n>>> from case_conversion import Converter\n>>> converter = Converter(text=\"FOO_BAR_STRING\")\n>>> converter.camel()\n'fooBarString'\n>>> converter.pascal()\n'FooBarString'\n```\n\nInitialize custom acronyms\n```python\n>>> from case_conversion import Converter\n>>> converter = Converter(acronyms=[\"BAR\"])\n>>> converter.camel(\"FOO_BAR_STRING\")\n'fooBARString'\n```\n\n### Convenience Functions\n\nFor backwards compatibility and convenience, all converters are available as top level functions. They are all shorthand for:\n\n`Converter(text, acronyms).converter_function()`\n\n```python\n>>> import case_conversion\n>>> case_conversion.dash(\"FOO_BAR_STRING\")\n'foo-bar-string'\n```\n\nSimple acronym detection comes included, by treating strings of capital letters as a single word instead of several single letter words.\n\nCustom acronyms can be supplied when needing to separate them from each other.\n```python\n>>> import case_conversion\n>>> case_conversion.snake(\"fooBADHTTPError\")\n'foo_badhttp_error'  # we wanted BAD and HTTP to be separate!\n>>> case_conversion.snake(\"fooBarHTTPError\", acronyms=['BAD', 'HTTP'])\n'foo_bad_http_error'  # custom acronyms achieved!\n```\n\nUnicode is fully supported - even for acronyms.\n\n```python\n>>> import case_conversion\n>>> case_conversion.const(u\"f\u00f3\u00f3-bar-string\")\nF\u00d3\u00d3_BAR_STRING\n>>> case_conversion.snake(\"fooBarH\u00d3\u00d3PError\", acronyms=['H\u00d3\u00d3P'])\n'foo_bar_h\u00f3\u00f3p_error'\n```\n\n\n\n## Install\n\n```\npip install case-conversion\n```\n\n## Contribute\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nThis package is being developed with [uv](https://github.com/astral-sh/uv) (-> [docs](https://docs.astral.sh/uv/)).\n\nCI will run tests and lint checks.\nLocally you can run them with:\n```bash\n# runs tests with coverage\nmake test\n# Runs linter (using ruff)\nmake lint\n# Auto-fix linter errors (using ruff --fix)\nmake format\n# run type check (using ty)\nmake tc\n```\n\n\n\n## Credits\n\nCredit goes to [Davis Clark's](https://github.com/jdc0589) as the author of the original plugin and its contributors (Scott Bessler, Curtis Gibby, Matt Morrison). Thanks for their awesome work on making such a robust and awesome case converter.\n\nFurther thanks and credit to [@olsonpm](https://github.com/olsonpm) for making this package dependency-free and encouraging package maintenance and best practices.\n\n\n## License\n\nUsing [MIT license](LICENSE.txt) with Davis Clark's Copyright\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Convert between different types of cases (unicode supported)",
    "version": "3.0.2",
    "project_urls": {
        "Issues": "https://github.com/AlejandroFrias/case-conversion/issues",
        "Source": "https://github.com/AlejandroFrias/case-conversion"
    },
    "split_keywords": [
        "camel",
        " case",
        " conversion",
        " convert",
        " kebab",
        " pascal",
        " snake",
        " spinal",
        " unicode"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "60b896fb174191e970c26df7b23a2efb710e1c9cd7a575bf4b9e057594e28540",
                "md5": "bc99b1aef6f50173c3aa2e11743f05c7",
                "sha256": "eb8e2834da59656966479cc03df144d00ed437161acb8046c564edb91dffeb3f"
            },
            "downloads": -1,
            "filename": "case_conversion-3.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc99b1aef6f50173c3aa2e11743f05c7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12199,
            "upload_time": "2025-08-27T23:37:44",
            "upload_time_iso_8601": "2025-08-27T23:37:44.849206Z",
            "url": "https://files.pythonhosted.org/packages/60/b8/96fb174191e970c26df7b23a2efb710e1c9cd7a575bf4b9e057594e28540/case_conversion-3.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4792fea5d4f8f859d9fa7700644da7ad0da3e3e1daadab9230960b59240f853a",
                "md5": "ed207d45bf82e2ef15eb97777629b519",
                "sha256": "2e5098c5e20d67282a5999531e7797c412daafcf646169e42066e30cba37a097"
            },
            "downloads": -1,
            "filename": "case_conversion-3.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ed207d45bf82e2ef15eb97777629b519",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 33387,
            "upload_time": "2025-08-27T23:37:46",
            "upload_time_iso_8601": "2025-08-27T23:37:46.027985Z",
            "url": "https://files.pythonhosted.org/packages/47/92/fea5d4f8f859d9fa7700644da7ad0da3e3e1daadab9230960b59240f853a/case_conversion-3.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-27 23:37:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AlejandroFrias",
    "github_project": "case-conversion",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "case-conversion"
}
        
Elapsed time: 0.43536s