{"id":8711,"library":"textcase","title":"textcase","description":"textcase is a lightweight, performant Python library designed for comprehensive text case conversions. It supports a wide array of cases like snake_case, kebab-case, and camelCase, and handles complex word boundaries including acronyms and non-ASCII characters. The library is notable for having zero external dependencies and a strong focus on accuracy and extensibility. It is actively maintained with frequent releases, with the current version 0.4.5, released in October 2025, ensuring Python 3.14 compatibility.","status":"active","version":"0.4.5","language":"en","source_language":"en","source_url":"https://github.com/zobweyt/textcase","tags":["text","case conversion","string","formatter","utility","camelcase","snakecase","kebabcase","pascalcase"],"install":[{"cmd":"pip install textcase","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The `case` and `convert` functions were part of an older API (pre-0.4.0) and are no longer the primary way to interact with the library. Direct methods on the `textcase` module are now used.","wrong":"from textcase import case, convert","symbol":"textcase","correct":"import textcase"}],"quickstart":{"code":"import textcase\n\ninput_string = \"Hello, beautiful_World! How are you in this wonderful-Day?\"\n\n# Convert to snake_case\nsnake_case_string = textcase.snake(input_string)\nprint(f\"Snake Case: {snake_case_string}\")\n\n# Convert to camelCase\ncamel_case_string = textcase.camel(input_string)\nprint(f\"Camel Case: {camel_case_string}\")\n\n# Convert to KEBAB-CASE\nkebab_case_string = textcase.kebab(input_string)\nprint(f\"Kebab Case: {kebab_case_string}\")\n\n# Convert to PascalCase\npascal_case_string = textcase.pascal(input_string)\nprint(f\"Pascal Case: {pascal_case_string}\")\n\n# Check if a string matches a specific case\nis_kebab = textcase.kebab.match(\"my-css-class\")\nprint(f\"'my-css-class' is Kebab Case: {is_kebab}\")\n\nis_snake = textcase.snake.match(\"my_css_class\")\nprint(f\"'my_css_class' is Snake Case: {is_snake}\")","lang":"python","description":"This quickstart demonstrates how to import the `textcase` library and use its direct methods to convert strings between common text cases like snake_case, camelCase, kebab-case, and PascalCase. It also shows how to use the `.match()` method to check if a string conforms to a specific case."},"warnings":[{"fix":"Update your imports from `from textcase import case, convert` to `import textcase` and adjust calls from `convert(string, case.SNAKE)` to `textcase.snake(string)`.","message":"Version 0.4.0 introduced a significant rewrite of the library's internal structure and API. The primary way to import and use the library changed from `from textcase import case, convert` to directly importing `textcase` and calling methods on the module (e.g., `textcase.snake()`).","severity":"breaking","affected_versions":"0.4.0 and later"},{"fix":"If Unicode normalization is required for your text, preprocess strings using Python's `unicodedata` module (e.g., `unicodedata.normalize('NFKC', my_string)`) before passing them to `textcase` functions.","message":"The library primarily focuses on case conversion based on defined word boundaries. For languages or specific contexts requiring Unicode normalization (e.g., decomposing accented characters before processing), `textcase` does not perform this automatically. Users should handle Unicode normalization separately if needed.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the release notes for versions 0.4.2 and 0.4.4 for details on punctuation stripping changes. Ensure your tests cover expected punctuation behavior, especially for edge cases.","message":"Behavior around stripping leading/trailing punctuation and handling specific delimiters was refined in versions 0.4.2 and 0.4.4. If you rely on very specific edge-case punctuation handling, test thoroughly after updating, as outputs might have subtly changed due to bug fixes and optimizations.","severity":"gotcha","affected_versions":"Pre-0.4.2"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install textcase` to install the library.","cause":"The 'textcase' library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'textcase'"},{"fix":"Update your code to use the new API. For example, replace `convert(my_string, case.SNAKE)` with `textcase.snake(my_string)`.","cause":"You are attempting to use the `convert` function, which was part of an older API (pre-0.4.0 rewrite). The current API uses direct methods on the `textcase` module.","error":"AttributeError: module 'textcase' has no attribute 'convert'"},{"fix":"Ensure you are using `import textcase` and calling methods directly on the module, e.g., `textcase.snake(\"my string\")`. The `case` object is no longer directly exposed in the same way for conversion functions.","cause":"This error can occur if you're trying to call `textcase.case.SNAKE()` as a function, or if you're attempting to access `case` or `convert` from an outdated import pattern after the 0.4.0 rewrite.","error":"TypeError: 'Case' object is not callable"}]}