Snake Case

Snake case (or "snake_case") is a naming convention that replaces spaces in compound words with underscores (_). It is commonly used by software developers for writing method and variable names in their source code, as well as when naming files used by their projects. While snake_case typically uses all lower-case letters, a version known as SCREAMING_SNAKE_CASE uses all capital letters.

In most programming languages, the names of methods, variables, and other elements cannot contain spaces. Developers use naming conventions like snake_case, camelCase, and PascalCase to make compound names readable while avoiding compilation errors. For example, the variable name my_first_variable is easier to read than myfirstvariable.

The underscores in snake_case recall a snake slithering on the ground
The underscores in snake_case recall a snake slithering on the ground

In many cases, it is up to the developer's preference which convention to use, but some programming languages have style guides that specify certain conventions for certain uses. For example, Python's style guide recommends a mix of several naming conventions for different uses:

  • Classes: PascalCase — class UserInfo
  • Functions: snake_case — print_message()
  • Methods: snake_case — draw_image()
  • Variables: snake_case — new_user_name
  • Constants: SCREAMING_SNAKE_CASE — MAX_VALUE

Other programming languages that use snake_case for variables, functions, and methods include Ruby, Rust, PHP, and Perl. Shell scripting languages, like Bash, also often use snake_case for variables and functions.

Updated May 15, 2023 by Brian P.

quizTest Your Knowledge

Which of the following apps uses augmented reality?

A
DuoLingo
0%
B
Pokémon Go
0%
C
Spotify
0%
D
ChatGPT
0%
Correct! Incorrect!     View the Augmented Reality definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Snake Case on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.