{"id":16543084,"url":"https://github.com/sanders41/camel-converter","last_synced_at":"2025-04-05T06:09:46.166Z","repository":{"id":37930412,"uuid":"359143725","full_name":"sanders41/camel-converter","owner":"sanders41","description":"Converts a string from snake case to camel case or camel case to snake case","archived":false,"fork":false,"pushed_at":"2025-04-02T10:16:06.000Z","size":1956,"stargazers_count":34,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T10:44:57.977Z","etag":null,"topics":["camel-case","conversion","converter","pascal-case","pydantic","python","snake-case"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanders41.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sanders41"]}},"created_at":"2021-04-18T12:59:16.000Z","updated_at":"2025-04-02T10:16:08.000Z","dependencies_parsed_at":"2023-02-12T05:00:33.244Z","dependency_job_id":"7d90fd5d-8f22-4fba-9e82-77b8cf8e2912","html_url":"https://github.com/sanders41/camel-converter","commit_stats":{"total_commits":580,"total_committers":8,"mean_commits":72.5,"dds":0.5017241379310344,"last_synced_commit":"0043262141ba27ccc4a8f7f31bd93209bd92e730"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanders41%2Fcamel-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanders41%2Fcamel-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanders41%2Fcamel-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanders41%2Fcamel-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanders41","download_url":"https://codeload.github.com/sanders41/camel-converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294541,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camel-case","conversion","converter","pascal-case","pydantic","python","snake-case"],"created_at":"2024-10-11T18:59:17.184Z","updated_at":"2025-04-05T06:09:46.143Z","avatar_url":"https://github.com/sanders41.png","language":"Python","funding_links":["https://github.com/sponsors/sanders41"],"categories":[],"sub_categories":[],"readme":"# Camel Converter\n\n[![Test Status](https://github.com/sanders41/camel-converter/actions/workflows/ci.yml/badge.svg?branch=main\u0026event=push)](https://github.com/sanders41/camel-converter/actions?query=workflow%3ACI+branch%3Amain+event%3Apush)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/camel-converter/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/camel-converter/main)\n[![Coverage](https://codecov.io/github/sanders41/camel-converter/coverage.svg?branch=main)](https://codecov.io/gh/sanders41/camel-converter)\n[![PyPI version](https://badge.fury.io/py/camel-converter.svg)](https://badge.fury.io/py/camel-converter)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/camel-converter?color=5cc141)](https://github.com/sanders41/camel-converter)\n\nIn JSON keys are frequently in camelCase format, while variable names in Python are typically\nsnake_case. The purpose of this pacakgae is to help convert between the two formats.\n\n## Usage\n\n- To convert from camel case to snake case:\n\n  ```py\n  from camel_converter import to_snake\n\n  snake = to_snake(\"myString\")\n  ```\n\n  This will convert `myString` into `my_string`\n\n- To convert a dictonary's keys from camel case to snake case:\n\n  ```py\n  from camel_converter import dict_to_snake\n\n  snake = dict_to_snake({\"myString\": \"val 1\"})\n  ```\n\n  This will convert `{\"myString\": \"val 1\"}` into `{\"my_string\": \"val 1\"}`. Non-string keys will be\n  left unchanged.\n\n  This is also available as a decorator for functions that return a dictionary.\n\n  ```py\n  from camel_converter.decorators import dict_to_snake\n\n  @dict_to_snake\n  def my_func() -\u003e dict[str, str]:\n      return {\"myString\": \"val 1\"}\n\n  snake = my_func()\n  ```\n\n  `my_func` will return `{\"my_string\": \"val 1\"}`. Non-string keys will be\n  left unchanged.\n\n- To convert from snake case to camel case:\n\n  ```py\n  from camel_converter import to_camel\n\n  camel = to_camel(\"my_string\")\n  ```\n\n  This will convert `my_string` into `myString`\n\n- To convert from a dictionary's keys from snake case to camel case:\n\n  ```py\n  from camel_converter import dict_to_camel\n\n  camel = to_camel({\"my_string\": \"val 1\"})\n  ```\n\n  This will convert `{\"my_string\": \"val 1\"}` into `{\"myString\": \"val 1\"}` Non-string keys will be\n  left unchanged.\n\n  This is also available as a decorator for functions that return a dictionary.\n\n  ```py\n  from camel_converter.decorators import dict_to_camel\n\n  @dict_to_camel\n  def my_func() -\u003e dict[str, str]:\n      return {\"my_string\": \"val 1\"}\n\n  camel = my_func()\n  ```\n\n  `my_func` will return `{\"myString\": \"val 1\"}`. Non-string keys will be\n  left unchanged.\n\n- To convert from snake to pascal case:\n\n  ```py\n  from camel_converter import to_pascal\n\n  pascal = to_pascal(\"my_string\")\n  ```\n\n  This will convert `my_string` into `MyString`\n\n- To convert from a dictionary's keys from snake case to pascal case:\n\n  ```py\n  from camel_converter import dict_to_pascal\n\n  pascal = to_pascal({\"my_string\": \"val 1\"})\n  ```\n\n  This will convert `{\"my_string\": \"val 1\"}` into `{\"MyString\": \"val 1\"}` Non-string keys will be\n  left unchanged.\n\n  This is also available as a decorator for functions that return a dictionary.\n\n  ```py\n  from camel_converter.decorators import dict_to_pascal\n\n  @dict_to_pascal\n  def my_func() -\u003e dict[str, str]:\n      return {\"my_string\": \"val 1\"}\n\n  pascal = my_func()\n  ```\n\n  `my_func` will return `{\"MyString\": \"val 1\"}`. Non-string keys will be\n  left unchanged.\n\n### Optional Extras\n\nAn optional extra is provided for [Pydantic](https://pydantic-docs.helpmanual.io/) that provides a\nbase class to automatically convert between snake case and camel case. To use this Pydantic class\ninstall camel converter with:\n\n```sh\npip install camel-converter[pydantic]\n```\n\nThen your Pydantic classes can inherit from CamelBase.\n\n```py\nfrom camel_converter.pydantic_base import CamelBase\n\n\nclass MyModel(CamelBase):\n    test_field: str\n\n\nmy_data = MyModel(**{\"testField\": \"my value\"})\nprint(my_data.test_field)\n```\n\nwill result in `my value` being printed.\n\nWith setting up your model in this way `myField` from the source, i.e. JSON data, will map to `my_field` in your model.\n\n## Contributing\n\nIf you are interested in contributing to this project please see our [contributing guide](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanders41%2Fcamel-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanders41%2Fcamel-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanders41%2Fcamel-converter/lists"}