Reference 2026-04-14
Text Case Conventions: When to Use Each
camelCase, snake_case, kebab-case, PascalCase: pick the right one for context.
Text case conventions are tribal. Mixing them in one codebase causes friction; following the local convention is what matters.
The Major Cases
|-------|---------|------------|
getUserByIdUserAccountget_user_by_idMAX_RETRY_COUNTuser-profileUser-ProfileContent-Type)getuserbyidPer-Language Defaults
- JavaScript/TypeScript: camelCase for variables, PascalCase for classes/components, SCREAMING_SNAKE for constants, kebab-case for filenames.
- Python: snake_case everywhere, PascalCase for classes, SCREAMING_SNAKE for constants.
- Rust: snake_case for everything except types and traits (PascalCase) and constants.
- Go: PascalCase exports, camelCase locals, no underscores or dashes.
- CSS: kebab-case classes, kebab-case custom properties (
--brand-color). - HTML attributes: kebab-case (
data-user-id). - JSON keys: usually camelCase, but snake_case when serving Python/Ruby backends.
Special Cases
- URLs: kebab-case is SEO-preferred (
/blog/text-case-conventionsover/blog/textCaseConventions). - Filenames: kebab-case for assets and components; snake_case for Python modules; PascalCase for React component files in some teams.
- Database: snake_case columns by SQL convention; some teams force lowercase to avoid quoting.
- Environment variables: SCREAMING_SNAKE always (
DATABASE_URL).
Acronyms
The fight no one wins:
getUrlvsgetURLvsgetUrlAddressparseHTMLvsparseHtml
Pick one. Modern style guides lean toward treating acronyms as words: getUrl, parseHtml. Easier to convert between cases mechanically.
Auto-conversion
function camelToKebab(s) { return s.replace(/[A-Z]/g, c => '-' + c.toLowerCase()); }
function kebabToCamel(s) { return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase()); }
Most codebases have these utilities. Use them in serialization layers, not scattered through business logic.
Convert between cases instantly with the [Text Case Converter](https://sdk.is/text-case-converter).