convert_case
Convert Rust strings between snake, kebab, camel, Pascal, title, and other cases
Repository Health
Technical Analysis
convert_case is a Rust library for converting strings between naming conventions such as snake_case, kebab-case, camelCase, PascalCase, Title Case, and more. It works by splitting an input string on configurable word boundaries and re-joining the resulting words with a target case’s pattern and delimiter.
The crate is no_std compatible and highly customizable: boundaries, patterns, and delimiters can each be swapped out or combined via a Converter builder, while the ccase! macro offers a terse one-line API for the common case of converting a string without any custom configuration.
What You Get
- The
Casingtrait adding.to_case(Case::X)and.from_case(Case::Y)methods directly on&str/String - A
Converterbuilder for composing custom boundary/pattern/delimiter pipelines beyond the built-in cases - The
ccase!macro for one-line conversions without importingCase/Casingexplicitly - Fourteen+ built-in cases (Snake, Constant, Ada, Kebab, Cobol, Train, Flat, UpperFlat, Pascal, Camel, Upper, Lower, Title, Sentence)
no_stdcompatibility, making it usable in embedded or constrained Rust environments
Common Use Cases
- Normalizing identifier names when generating code or config from a schema (e.g. converting API field names to snake_case for a Rust struct)
- Converting slugs or URLs between kebab-case and human-readable Title Case for display
- Building CLI tools (like the companion
ccasebinary) that reformat text case interactively - Adapting external API responses with inconsistent casing (camelCase JSON) to a project’s internal naming convention
Under The Hood
Architecture — The crate splits responsibilities across src/boundary.rs (566 lines, defines where a string should be split into words — e.g. LowerUpper, Underscore, Hyphen), src/pattern.rs (273 lines, defines how the resulting words are capitalized/joined), src/case.rs (410 lines, the Case enum mapping named cases to a boundary+pattern+delimiter combination), and src/converter.rs (436 lines, the Converter builder that lets users override the automatic boundary detection). src/lib.rs (804 lines) ties these together behind the Casing trait and the ccase!/case! macros, so a call like "my_var".to_case(Case::Camel) resolves to boundary-splitting the input into words, then applying the target case’s pattern.
Tech Stack — Pure Rust 2021 edition, no_std-compatible, with a single runtime dependency (unicode-segmentation for correct grapheme-aware word splitting). Dev dependencies include criterion for benchmarking (benches/convert.rs) and rstest for parameterized tests. Distributed via Nix flake (flake.nix/flake.lock) alongside the standard Cargo packaging, and a justfile for common dev tasks.
Code Quality — Tests live under tests/ using rstest for table-driven case coverage, and the README documents an active changelog spanning nine minor versions (0.7 through 0.11) with explicit breaking-change notes for each — a level of API-evolution discipline uncommon in small utility crates. Source files are focused and under 600 lines each, and the crate maintains #![no_std] compatibility as an explicit design constraint tested in CI.
API Design — The library exposes three levels of ergonomics: the single-line ccase! macro for the common case, the Casing trait for idiomatic .to_case() method chaining, and the Converter builder for advanced customization — letting simple call sites stay simple while still supporting fully custom boundary/pattern combinations for power users. The README’s changelog shows deliberate API simplification over time (e.g. reverting Pattern/Boundary from function-based back to enum-based APIs after user feedback).
Used by 5 apps in this directory
Fyrox
Game Development
A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts
GitButler
Developer Tools · Devops · AI Development
Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.
Meilisearch
Search
Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.
PostgresML
Databases · AI Development
Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.
Vibe Kanban
AI Agents · AI Code Assistants · Project Management
A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.