Common Naming Conventions Explained: camelCase / snake_case / kebab-case
Different programming languages and scenarios have different text formatting requirements. Here are the four most commonly used naming conventions:
- camelCase (lower camel): First word starts lowercase, subsequent words start uppercase. E.g.,
userName,getUserId. Widely used for variables and functions in JavaScript, Java, TypeScript. - PascalCase (upper camel): Every word starts with an uppercase letter. E.g.,
UserService,HttpClient. Commonly used for class names in C#, Java. - snake_case (snake): All words lowercase, connected by underscores. E.g.,
user_name,created_at. The dominant style in Python, Ruby, and database field names. - kebab-case (spinal): All words lowercase, connected by hyphens. E.g.,
user-name,font-size. Mainly used in HTML attributes, CSS class names, and URL paths.