{"id":3428,"library":"camel-converter","title":"Camel Converter","description":"Camel Converter is a Python library designed to effortlessly convert strings and dictionary keys between camel case, snake case, and pascal case. It's particularly useful for handling JSON data where keys are often in camelCase, facilitating seamless integration with Python's snake_case conventions. The library also provides decorators for automatic dictionary key conversion in function returns and offers integration with Pydantic models. The current version is 5.1.0.","status":"active","version":"5.1.0","language":"python","source_language":"en","source_url":"https://github.com/sanders41/camel-converter","tags":["case-conversion","camel-case","snake-case","pascal-case","pydantic","json-conversion"],"install":[{"cmd":"pip install camel-converter","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for using the `CamelBase` Pydantic model integration.","package":"pydantic","optional":true}],"imports":[{"symbol":"to_snake","correct":"from camel_converter import to_snake"},{"symbol":"to_camel","correct":"from camel_converter import to_camel"},{"symbol":"to_pascal","correct":"from camel_converter import to_pascal"},{"symbol":"dict_to_snake","correct":"from camel_converter import dict_to_snake"},{"symbol":"dict_to_camel","correct":"from camel_converter import dict_to_camel"},{"symbol":"dict_to_pascal","correct":"from camel_converter import dict_to_pascal"},{"symbol":"dict_to_snake (decorator)","correct":"from camel_converter.decorators import dict_to_snake"},{"symbol":"dict_to_camel (decorator)","correct":"from camel_converter.decorators import dict_to_camel"},{"symbol":"dict_to_pascal (decorator)","correct":"from camel_converter.decorators import dict_to_pascal"},{"note":"Requires Pydantic to be installed separately.","symbol":"CamelBase","correct":"from camel_converter.pydantic_base import CamelBase"}],"quickstart":{"code":"from camel_converter import to_snake, to_camel, dict_to_snake\nfrom camel_converter.decorators import dict_to_camel\nfrom pydantic import BaseModel # For CamelBase example\n\n# String conversion\nsnake_case_string = to_snake('myCamelCaseString')\nprint(f\"'myCamelCaseString' to snake_case: {snake_case_string}\")\n\ncamel_case_string = to_camel('my_snake_case_string')\nprint(f\"'my_snake_case_string' to camelCase: {camel_case_string}\")\n\n# Dictionary key conversion\ncamel_dict = {'firstName': 'John', 'lastName': 'Doe', 'dateOfBirth': '1990-01-01'}\nsnake_dict = dict_to_snake(camel_dict)\nprint(f\"CamelCase dict to snake_case: {snake_dict}\")\n\n# Decorator usage\n@dict_to_camel\ndef get_data_from_db() -> dict:\n    # Simulate fetching data with snake_case keys\n    return {'user_id': 123, 'user_name': 'test_user'}\n\napi_response = get_data_from_db()\nprint(f\"Decorated function output (snake_case to camelCase): {api_response}\")\n\n# Pydantic integration (requires 'pydantic' to be installed)\ntry:\n    from camel_converter.pydantic_base import CamelBase\n\n    class User(CamelBase):\n        first_name: str\n        last_name: str\n\n    user_data_camel = {'firstName': 'Jane', 'lastName': 'Smith'}\n    user_obj = User(**user_data_camel)\n    print(f\"Pydantic CamelBase model from camelCase input: {user_obj.first_name} {user_obj.last_name}\")\nexcept ImportError:\n    print(\"Pydantic not installed. Skipping CamelBase example.\")","lang":"python","description":"This quickstart demonstrates basic string and dictionary key conversion using `to_snake`, `to_camel`, `dict_to_snake`, and decorator-based conversion with `dict_to_camel`. It also includes an example of using `CamelBase` for Pydantic models, which automatically handles camelCase to snake_case mapping for model instantiation."},"warnings":[{"fix":"For deeply nested structures, manually apply `dict_to_snake` or `dict_to_camel` at each level, or consider a custom recursive function.","message":"The library directly converts strings or dictionary keys. For converting complex nested structures (lists of dictionaries, deeply nested dictionaries), ensure you apply the conversion functions recursively or use tools built for such scenarios.","severity":"gotcha","affected_versions":"All"},{"fix":"Be aware that dictionaries with mixed key types will only have their string keys transformed. If non-string keys need transformation (e.g., `(1, 'someValue')` to `(1, 'some_value')`), convert them explicitly before or after processing.","message":"When using `dict_to_snake`, `dict_to_camel`, or `dict_to_pascal`, only string keys are converted. Non-string keys (e.g., integers, tuples) in a dictionary will be left unchanged in the output.","severity":"gotcha","affected_versions":"All"},{"fix":"Install Pydantic separately via `pip install pydantic` if you intend to use `CamelBase` for Pydantic model definitions.","message":"The `CamelBase` Pydantic integration requires Pydantic to be installed as an additional dependency. It is not part of the `camel-converter` core package dependencies.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your environment uses Python 3.10 or a newer version.","message":"The library explicitly requires Python 3.10 or newer. Attempting to install or run it on older Python versions will result in compatibility errors.","severity":"gotcha","affected_versions":"<5.0.0 (older versions might support earlier Python), >=5.0.0 (requires >=3.10)"}],"env_vars":null,"search_vec":"'5.1.0':71 'also':50 'automat':54 'camel':1,3,18,76 'camel-cas':75 'camelcas':38 'case':19,21,24,46,73,77,80,83 'case-convers':72 'convent':47 'convers':57,74,87 'convert':2,4,12 'current':68 'data':32 'decor':52 'design':9 'dictionari':15,55 'effortless':11 'facilit':39 'function':59 'handl':30 'integr':41,63 'json':31,86 'json-convers':85 'key':16,34,56 'librari':8,49 'model':66 'offer':62 'often':36 'particular':27 'pascal':23,82 'pascal-cas':81 'provid':51 'pydant':65,84 'python':7,43 'return':60 'seamless':40 'snake':20,45,79 'snake-cas':78 'string':13 'use':28 'version':69","created_at":"2026-04-11T17:28:41.698162+00:00","updated_at":"2026-04-16T01:21:52.237799+00:00","problems":[{"fix":"Run `pip install camel-converter` to install the package.","cause":"The 'camel-converter' library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'camel_converter'"},{"fix":"Install camel-converter with the pydantic extra: `pip install camel-converter[pydantic]`.","cause":"The optional 'pydantic' extra for camel-converter was not installed, which is required to use the CamelBase class for Pydantic integration.","error":"ModuleNotFoundError: No module named 'camel_converter.pydantic_base'"},{"fix":"Manually apply the conversion functions recursively to each nested dictionary, or implement a custom recursive utility function for deep conversion. The library does not provide a built-in deep conversion for dictionaries.","cause":"The `dict_to_snake`, `dict_to_camel`, and `dict_to_pascal` functions in `camel-converter` only perform a shallow conversion of top-level dictionary keys by default and do not recursively process nested dictionaries.","error":"Keys in nested dictionaries are not converted (e.g., {'outerKey': {'innerKey': 'value'}} becomes {'outer_key': {'innerKey': 'value'}})"},{"fix":"Ensure that all dictionary keys you intend to convert are strings. If non-string keys require transformation, convert them to strings before processing with `camel-converter` or handle them explicitly.","cause":"The `dict_to_snake`, `dict_to_camel`, and `dict_to_pascal` functions in `camel-converter` are designed to only convert string keys within dictionaries, leaving non-string keys (like integers or tuples) unchanged.","error":"Non-string dictionary keys are not converted (e.g., {1: 'value', 'stringKey': 'value'} becomes {1: 'value', 'string_key': 'value'})"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"5.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/camel-converter/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}