Snake case

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Snake case (or snake_case) is the practice of writing compound words or phrases in which the elements are separated with one underscore character (_) and no spaces, with each element's initial letter usually lowercased within the compound and the first letter either upper or lower case—as in "foo_bar", "hello_world". It is commonly used in computer code for variable names, and function names, and sometimes computer filenames.[1] At least one study found that readers can recognize snake case values more quickly than camel case. [2]


When each word is delimited by a hyphen instead of an underscore, the practice is popularly known as kebab-case or lisp-case; also, the uppercased initial word character variant is known as Train-Case, and the all lowercased variant is known as spinal-case.[3][4] Screaming snake case is similar to snake_case, with letters written in UPPERCASE, as in: THIS_IS_AN_EXAMPLE.

Snake Camel or Oxford Case when words are separated by underscores and each word is capitalised and all abbreviations are capitalised. This_Is_An_Example_Including_An_ID_Number. This case was invented (or formalised) in Oxford UK in 2014.

Languages that use snake case as convention[edit]

  • OCaml for variable and function names
  • C++
  • Erlang, for function names
  • Perl
  • PHP, for variable names and function names
  • Python, for variable names, function names, and method names
  • Ruby
  • Rust, for function names

See also[edit]


  1. ^ eg. in Python and Ruby; see Naming convention (programming)
  2. ^ "An Eye Tracking Study on camelCase and under_score Identifier Styles". 
  3. ^ "StackOverflow - What's the name for snake_case with dashes?". 
  4. ^ "Camel_SNAKE-kebab".