Programming Naming Conventions: Camel, Snake, Kebab
Where camelCase, snake_case, and kebab-case come from and which languages and tools use which convention.
There are only two hard things in Computer Science: cache invalidation and naming things. Part of the naming struggle is deciding how to write the name.
The Big Three
1. camelCase
Start with lowercase, then capitalize each subsequent word.myVariableName
Used in: JavaScript, Java, Swift, Go.
2. snake_case
All lowercase, separated by underscores.my_variable_name
Used in: Python, Ruby, SQL, Rust.
3. kebab-case
All lowercase, separated by hyphens.my-variable-name
Used in: URLs, CSS classes, Lisp.
Other Contenders
- PascalCase: Like camelCase but starts capitalized (
MyClass). Standard for classes in most languages. - SCREAMING_SNAKE_CASE: Used for constants (
MAX_RETRIES).
Why It Matters
Consistency is key. Mixing styles makes code hard to read. If you're working with an API that returns snake_case JSON but your frontend uses camelCase, you'll need to transform the data.
Language-Specific Guidelines
JavaScript/TypeScript
- Variables & Functions: camelCase (
getUserById) - Classes & Interfaces: PascalCase (
UserService) - Constants: SCREAMING_SNAKE_CASE or camelCase (
API_BASE_URLorapiBaseUrl) - Private Members: Leading underscore optional (
_privateMethod)
Python
- Variables & Functions: snake_case (
get_user_by_id) - Classes: PascalCase (
UserService) - Constants: SCREAMING_SNAKE_CASE (
API_BASE_URL) - Private Members: Leading underscore (
_private_method)
SQL
- Tables & Columns: snake_case (
user_accounts,created_at) - Some databases: PascalCase for tables, camelCase for columns (SQL Server convention)
The Friction of Crossing Boundaries
The biggest headache arises when moving data between systems with different conventions:
- Database → API: PostgreSQL (snake_case) to JavaScript API (camelCase)
- API → Frontend: REST API (camelCase) to CSS (kebab-case)
- Config Files: YAML (kebab-case) to environment variables (SCREAMING_SNAKE_CASE)
This mismatch requires transformation layers, which adds complexity and potential bugs.
Best Practices
- Be consistent: Pick one style per project and stick to it
- Follow language conventions: Use the style your language community expects
- Use linters: ESLint, Pylint, and similar tools enforce naming conventions automatically
- Document exceptions: If you must deviate, document why
- Consider team preferences: Consistency within a team is more important than "perfect" style
Automate the Switch
Refactoring a large codebase or converting a list of database columns? Don't do it manually. Manual conversion is:
- Time-consuming and error-prone
- Likely to introduce typos
- Inconsistent across different parts of the codebase
- Repetitive and boring (leading to mistakes)
Our Text Case Converter can instantly transform blocks of text between any of these formats. It handles:
- All major naming conventions (camelCase, snake_case, kebab-case, PascalCase, etc.)
- Bulk conversion of multiple identifiers
- Preservation of acronyms (optional)
- Consistent formatting across your entire codebase
Perfect for refactoring, generating TypeScript interfaces from SQL schemas, or converting API response keys. Save yourself from repetitive strain injury and ensure consistency.
Try these tools
Use these tools alongside this guide
Part of the ThenCatch blog. Learn more about us or browse more guides.