DEV Community

Cover image for Four Case Styles you should know!
SYED MAZHAR ALI RAZA
SYED MAZHAR ALI RAZA

Posted on • Edited on

4 1 1 1

Four Case Styles you should know!

In programming, we are mostly not allowed to use space characters between words because it is interpreted as the end of identifier or beginning of something new.
Instead, we use certain naming conventions in order to use multiple words for naming variables, classes, functions, etc. in the source code.
Following are the most popular case styles used in programming:

  1. Camel case
  2. Pascal case
  3. Snake case
  4. Kebab case

Camel Casing:

camelCase
For using the camel case style, the rule is to remove spaces and capitalize each word, except the first one.
Eg: first name will be written as firstName in this case style.
Application: The camel case style is used as the naming convention of variables and functions in various programming languages like JavaScript.

Pascal Casing:

PascalCase
For using the pascal case style, the rule is to remove spaces and capitalize each word, including the first one.
Eg: first name will be written as FirstName in this case style.
Application: In Java, all classes, interfaces and enums are expected to use Pascal case. C# uses PascalCase for namespaces and even public methods.

Kebab Casing:

kebab-case
The craving makes it difficult to write but by gathering all my self-control, here I go. The rule for kebab casing is to remove spaces and then add a hyphen "-" between each word.
Eg: first name will be written as first-name in this case style.
Application: In CSS, property names are written in this style. This style is also often used in URLs.

Snake Casing:

snake_case
For using the snake case style, the rule is to remove spaces and add an underscore "_" to separate each word.
Eg: first name will be written as first_name in this case style.
Application: It is used conventionally in declaring database field names. Python uses the style for variable names, function names, method names, and module or package (i.e. file) names. PHP uses SCREAMING_SNAKE_CASE for class constants.

Auth0

Auth0 now, thank yourself later. 😌

Scaling made simple. With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

Learn more

Top comments (1)

Collapse
 
caseconverter profile image
Case Converter

A great breakdown of the four main case styles in programming: camel case, pascal case, snake case, and kebab case. Each style has its own set of rules and applications in different programming languages. Camel case is used for variables and functions in languages like JavaScript, Pascal case is for class names in languages like Java and C#, snake case is commonly used in Python and for database field names, kebab case is seen in CSS and URLs, and SCREAMING_SNAKE_CASE is used for constants in languages like Python and PHP. It's important to follow the right conventions for readability and consistency in your codebase.

For switching between these case styles quickly, check out our converters: camel case converter, pascal case converter, snake case converter, kebab case converter, screaming snake case converter.

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay