Text Case Conventions in Programming: camelCase, snake_case, and kebab-case
Why does naming convention matter, which languages use which style, and how to convert between them without thinking too hard about it.
The first thing a code reviewer notices is naming consistency. A codebase mixing firstName, first_name, and FirstName for the same concept type is harder to read and signals inconsistent practices. Conventions exist to eliminate the question 'how should I name this?'
The Conventions at a Glance
- camelCase: JavaScript/TypeScript variables and functions, JSON keys, Java/Swift properties
- PascalCase: Class names everywhere, React components, TypeScript types/interfaces
- snake_case: Python variables/functions, SQL columns, Ruby, configuration files
- SCREAMING_SNAKE_CASE: Constants in most languages (MAX_RETRIES, API_KEY)
- kebab-case: CSS classes, HTML attributes, URL paths, CLI flags
Why It Matters for APIs
APIs often cross language boundaries: a Python backend (snake_case) serves data consumed by a JavaScript frontend (camelCase). The common solution: serialize JSON with camelCase keys regardless of internal backend convention, and have the frontend convert if needed. Inconsistent API naming forces consumers to guess whether the property is userId, user_id, or UserId.
Converting Between Cases
Pasting content between systems with different conventions is common. Our Text Case Converter handles all the standard transformations without the manual work.
File and Folder Names
Web URLs are case-sensitive on most servers — /Blog/Post and /blog/post are different URLs. CSS files, HTML pages, and URLs should use kebab-case. JavaScript/TypeScript modules: kebab-case for file names (user-service.ts) matches the npm convention and avoids case sensitivity issues across Mac (case-insensitive filesystem) and Linux (case-sensitive) environments.
Linter enforcement
ESLint's camelcase rule and Prettier enforce naming in JavaScript. For Python, pylint and flake8 enforce PEP 8 conventions. Setting these up in a new project prevents convention drift and eliminates style arguments in code reviews.
Frequently Asked Questions
What is camelCase?+
What is snake_case?+
What is kebab-case?+
Does naming convention affect code performance?+
🔧 Free Tools Used in This Guide
FreeToolKit Team
FreeToolKit Team
We build free browser-based tools and write practical guides that skip the fluff.
Tags: