164

I'm interested in the different kinds of identifier cases, and what people call them. Do you know of any additions to this list, or other alternative names?

  • myIdentifier : Camel case (e.g. in java variable names)
  • MyIdentifier : Capital camel case (e.g. in java class names)
  • my_identifier : Snake case (e.g. in python variable names)
  • my-identifier : Kebab case (e.g. in racket names)
  • myidentifier : Flat case (e.g. in java package names)
  • MY_IDENTIFIER : Upper case (e.g. in C constant names)
10
  • 46
    My1d3nT1F13r : Leet case ^_^ Commented Jun 26, 2013 at 17:03
  • 6
    Why is it called kebab-case? Where did the name come from? Commented Oct 3, 2013 at 21:53
  • 12
    Imagine a shish-kebab being run through the identifier. Commented Feb 3, 2014 at 5:30
  • 14
    to correct @AustinCoryBart 's response about shish-kebab, imagine a skewer being run through the identifier. The dash (-) between words resembles the skewer, and the words resemble to the meat and vegetables on the shish-kebab skewer. Commented Apr 25, 2015 at 19:07
  • 12
    @AustinCoryBart shish (actually spelt şiş) means skewer in Turkish Commented Feb 21, 2017 at 13:54

7 Answers 7

128
  • flatcase or mumblecase
  • kebab-case. Also called caterpillar-case, param-case, dash-case, hyphen-case, lisp-case, spinal-case and css-case
  • camelCase
  • PascalCase or CapitalCamelCase
  • snake_case or c_case
  • CONSTANT_CASE, MACRO_CASE, UPPER_CASE or SCREAM_CASE
  • COBOL-CASE or TRAIN-CASE
  • Ada_Case
Sign up to request clarification or add additional context in comments.

Comments

31

Names are either generic, after a language, or colorful; most don’t have a standard name outside of a specific community.

There are many names for these naming conventions (names for names!); see Naming convention: Multiple-word identifiers, particularly for CamelCase (UpperCamelCase, lowerCamelCase). However, many don’t have a standard name. Consider the Python style guide PEP 0008 – it calls them by generic names like “lower_case_with_underscores”.

One convention is to name after a well-known use. This results in:

  • PascalCase
  • MACRO_CASE (C preprocessor macros)

…and suggests these names, which are not widely used:

  • c_case (used in K&R and in the standard library, like size_t)
  • lisp-case, css-case
  • COBOL-CASE

Alternatively, there are illustrative names, of which the best established is CamelCase. snake_case is more recent (2004), but is now well-established. kebab-case is yet more recent and still not established, and may have originated on Stack Overflow! (What's the name for dash-separated case?) There are many more colorful suggestions, like caterpillar-case, Train-case (initial capital), caravan-case, etc.

1 Comment

Shouldn't it be "caterpillar-case" instead of "caterpillar_case"?
29
+--------------------------+-------------------------------------------------------------+
| Formatting               | Name(s)                                                     |
+--------------------------+-------------------------------------------------------------|
| namingidentifier         | flat case/Lazy Case                                         |
| NAMINGIDENTIFIER         | upper flat case                                             |
| namingIdentifier         | (lower) camelCase, dromedaryCase                            |
| NamingIdentifier         | (upper) CamelCase, PascalCase, StudlyCase, CapitalCamelCase |
| naming_identifier        | snake_case, snake_case, pothole_case, C Case                |
| Naming_Identifier        | Camel_Snake_Case                                            |
| NAMING_IDENTIFIER        | SCREAMING_SNAKE_CASE, MACRO_CASE, UPPER_CASE, CONSTANT_CASE |
| naming-identifier        | Kebab Case/caterpillar-case/dash-case, hyphen-case,         |
|                          | lisp-case, spinal-case and css-case                         |
| NAMING-IDENTIFIER        | TRAIN-CASE, COBOL-CASE, SCREAMING-KEBAB-CASE                |
| Naming-Identifier        | Train-Case, HTTP-Header-Case                                |
| _namingIdentifier        | Undercore Notation (prefixed by "_" followed by camelCase   |
| datatypeNamingIdentifier | Hungarian Notation (variable names Prefixed by metadata     |
|                          | data-types which is out-dated)                              |
|--------------------------+-------------------------------------------------------------+

Updated:

+-------------------------+-------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| Formatting              | Name(s)                             | Used In Programming Languages                                                                                       |
+-------------------------+-------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| namingidentifier        | flat case, lazy case                | Rare; can be seen in scripting or configuration languages (e.g., some older shell scripts).                         |
| NAMINGIDENTIFIER        | upper flat case                     | Common in COBOL, FORTRAN, and old-fashioned macros in C or assembly.                                                |
| namingIdentifier        | camelCase, dromedaryCase            | Popular in Java, JavaScript, C#, Swift, Kotlin, and TypeScript (for variables, functions, and properties).          |
| NamingIdentifier        | PascalCase, StudlyCase              | Common in C#, Java, Python (class names), JavaScript, and Swift (type or class definitions).                        |
| naming_identifier       | snake_case                          | Used in Python (functions, variables), Ruby, C (file names), and PostgreSQL (database column names).                |
| Naming_Identifier       | Camel_Snake_Case                    | Seen in some modern APIs and frameworks; less common, but may appear in C++ or Rust for hybrid naming styles.       |
| NAMING_IDENTIFIER       | SCREAMING_SNAKE_CASE                | Widely used for constants in Python, Ruby, Java, C, and C++.                                                        |
| naming-identifier       | kebab-case                          | Common in CSS, HTML class names, and configuration files (e.g., YAML or JSON keys).                                 |
| NAMING-IDENTIFIER       | screaming-kebab-case                | Rare; used in some legacy systems, COBOL, or JSON configuration keys that require emphasis.                         |
| Naming-Identifier       | Train-Case, HTTP-Header-Case        | Common in HTTP headers (e.g., Content-Type) and some JSON API field names.                                          |
| _namingIdentifier       | Underscore Notation                 | Used in Python (private variables/methods) and C++ (reserved fields or private members).                            |
| __namingIdentifier      | Double Underscore Prefix            | Python ("magic methods" like __init__), C++ (special compiler-reserved fields).                                     |
| $$namingIdentifier      | Dollar Notation                     | JavaScript (jQuery $, AngularJS components like $$evalAsync), shell scripts (variable names).                       |
| __NAMING_IDENTIFIER__   | Double Underscore All Caps          | Python (special constants like __FILE__), C/C++ (macros and preprocessor constants).                                |
| namingIdentifier123     | CamelCase with Numeric Suffix       | Common in JavaScript, Java, and Python for versioning or temporary variables (e.g., tempVar1).                      |
| naming_identifier_123   | Snake Case with Numeric Suffix      | Seen in Python, Ruby, and SQL for variable or column names (e.g., user_id_1).                                       |
| naming.identifier       | Dot Notation                        |   Common in JavaScript (object properties), Python (module attributes), and C# (namespaces).                        |
| NAMING.Identifier       | Dot Notation with Uppercase Prefix  | Used in Java (packages like COM.ORG.UTILITY), C# (namespace organization).                                          |
| namingIdentifier!       | Punctuation-Suffixed Case           | Seen in Ruby (method names like save! for danger methods) and Elixir (functions).                                   |
| naming~identifier       | Tilde Case                          | Rare; used in symbolic file paths or configurations (e.g., Unix ~ for home directories).                            |
| datatypeNamingIdentifier| Hungarian Notation                  | Historical usage in C, C++, and Visual Basic; prefixes indicate data type (e.g., strName for a string, iCount for an integer).                                                                                                          |
+-------------------------+-------------------------------------+---------------------------------------------------------------------------------------------------------------------+
         

1 Comment

I like that you added Hungarian notation (still quite common, esp. in C/C++ and many official interop libs and win32). Note that it is common to use _leading_underscore notation in many languages for locals/private variables. Some languages, like F#, attach special meaning to leading underscores (i.e., you can use it for temp. unused vars).
9

MyVariable : Pascal Case => Used for Class

myVariable : Camel Case => Used for variable at Java, C#, etc.

myvariable : Flat Case => Used for package at Java, etc.

my_variable : Snake Case => Used for variable at Python, PHP, etc.

my-variable : Kebab Case => Used for css

Comments

2

The most common case types: Camel case Snake case Kebab case Pascal case Upper case (with snake case)

camelCase camelCase must (1) start with a lowercase letter and (2) the first letter of every new subsequent word has its first letter capitalized and is compounded with the previous word.

An example of camel case of the variable camel case var is camelCaseVar.

snake_case snake_case is as simple as replacing all spaces with a "_" and lowercasing all the words. It's possible to snake_case and mix camelCase and PascalCase but imo, that ultimately defeats the purpose.

An example of snake case of the variable snake case var is snake_case_var.

kebab-case kebab-case is as simple as replacing all spaces with a "-" and lowercasing all the words. It's possible to kebab-case and mix camelCase and PascalCase but that ultimately defeats the purpose.

An example of kebab case of the variable kebab case var is kebab-case-var.

PascalCase PascalCase has every word starts with an uppercase letter (unlike camelCase in that the first word starts with a lowercase letter).

An example of pascal case of the variable pascal case var is PascalCaseVar.

Note: It's common to see this confused for camel case, but it's a separate case type altogether.

UPPER_CASE_SNAKE_CASE UPPER_CASE_SNAKE_CASE is replacing all the spaces with a "_" and converting all the letters to capitals.

an example of upper case snake case of the variable upper case snake case var is UPPER_CASE_SNAKE_CASE_VAR.

1 Comment

UPPER_CASE_SNAKE_CASE also known as SCREAMING_SNAKE_CASE
2

For Python specifically, it is best to use snake_case for variable and function names, UPPER_CASE for constants (even though we don't have any keywords that specifically say that our variable is a constant) and PascalCase for class names.

camelCase is not recommended for Python (although languages such as Javascript have it as their main casing), and kebab-case would be invalid as Python names cannot contain a hypen (-).

variable_name = 'Hello World!'

def function_name():
    pass

CONSTANT_NAME = 'Constant Hello World!!'

class ClassName:
    pass

Comments

-1

Do you know of any additions to this list

Although this is one old question, when I wrote this answer, there is no one saying about title case (see wikipedia).

"The Quick Brown Fox Jumps over the Lazy Dog"

A mixed-case style with all words capitalised, except for certain subsets (particularly articles and short prepositions and conjunctions) defined by rules that are not universally standardised.

Notice for VSCode and Python, that means start case in wikipedia definition (JS lib lodash uses the latter naming). More details are show in this reddit comment thread.

"The Quick Brown Fox Jumps Over The Lazy Dog"

Start case, initial caps or proper case is a simplified variant of title case. In text processing, start case usually involves the capitalisation of all words irrespective of their part of speech.

1 Comment

OP is asking about identifiers. Title case applies to whole sentences, which are not valid as identifiers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.