714

This is PascalCase: SomeSymbol

This is camelCase: someSymbol

This is snake_case: some_symbol

So my questions is whether there is a widely accepted name for this: some-symbol? It's commonly used in urls.

13
  • 16
    @CatPlusPlus Lisp uses this-case, and because Google treats a - as a space, almost every SEO friendly URL uses it too.
    – lmirosevic
    Commented Jun 30, 2012 at 10:37
  • 37
    @CatPlusPlus 1) URLs are NOT irrelevant to programming languages. They are one of the most frequent resource programming languages use. Some languages even treat URLs as a first class object. In Go, while not first class, URLs are used for importing packages. 2) The dash-separated-string is quite common in several languages (the LISP family for one), and also in anxilliary languages used in programming, like CSS. What's a "minority" for you, it's the language others work day in and out. We're not all VB6 programmers.
    – Hejazzman
    Commented Nov 8, 2014 at 6:55
  • 7
    kebab-case isn't just used in LISP, but in CSS and all its new-fangled Turing-complete preprocessors, it's used in XSLT and XPath and in any other XML-based language. They are far from a minority.
    – Tobia
    Commented Mar 29, 2015 at 21:15
  • 4
  • 7
    EJoshua: This is a practical question because talking about identifiers, variable names, etc is part of software developer. It is also answerable in the social-science sense, because we can review (1) source code repositories, perhaps combined with popularity weighting as well as (2) natural language trends (via Google or otherwise). Additionally, these terms are just so much fun. Don't poop on our party. So I'm going to officially rain on your party-pooping party.
    – David J.
    Commented Jun 25, 2021 at 19:21

15 Answers 15

600

This is known as dash-case or kebab-case.

No other terms have achieved wide adoption, though there are various other coinings out there including hyphen-case, caterpillar-case, lisp-case, train-case, url-case, slug-case, and css-case.

It seems kebab-case in particular has entered the lexicon of several javascript code libraries.

26
  • 162
    The linked wikipedia article currently has a reference that links back to this stack overflow question... specifically to the kebab-case question. Maybe using wikipedia as a source wasn't a clever idea.
    – dequis
    Commented Jul 28, 2014 at 9:01
  • 8
    @BenLee I'm the one you felt butchered the copy - for which apologies. Note that spinal-case/Train-Case were added to Wikipedia on 2012-10-07 without reference by an anonymous user from an IP address without other Wikipedia history. I couldn't find any other evidence for those terms that didn't circularly go back to Wikipedia. On the other hand, I felt this StackOverflow question did offer evidence ‎that kebab-case has a community of users that doesn't depend on something entered into a Wikipedia article without evidence. I hope that's enough to avoid the original research charge. Commented Nov 3, 2014 at 6:38
  • 8
    I was tempted to remove spinal-case and Train-Case entirely (as likely vandalism); but maybe longstanding Wikipedia vandalism can actually create evidence for itself. That's what seems to have happened here. Commented Nov 3, 2014 at 6:40
  • 13
    I like "catipillar-case" since it's squished and then long, and keeps with the animal theme Commented Jan 29, 2016 at 4:40
  • 73
    kebab-case-because it-looks-like-the-words-are skewered-on-a-kebab
    – Aaron_H
    Commented Dec 16, 2016 at 5:10
524

It's referred to as kebab-case. See lodash docs.

21
  • 214
    Here's a reference, that makes it official ;)
    – Andreas
    Commented Sep 21, 2012 at 16:45
  • 13
    Here's another reference: github.com/qerub/camel-snake-kebab ;)
    – qerub
    Commented Nov 6, 2012 at 19:49
  • 12
    The recursion in the reference means it's that much more Lisp-like. Commented Jan 11, 2013 at 20:59
  • 151
    I upvoted this answer not because I believe it's the right one, but because I want it to be the right one. Commented Jan 20, 2014 at 23:10
  • 50
    I love the citogenesis going on here. This answer links to lodash which links to wikipedia which links to this answer!
    – gilly3
    Commented Jun 5, 2015 at 18:20
39

It's also sometimes known as caterpillar-case

9
  • 73
    caterpillar-case makes much more sense than kebab-case, because camels, snakes, and caterpillars are all kinds of living creature while a kebab is not. Commented Jan 11, 2015 at 2:02
  • 29
    @DairaHopwood cs.helsinki.fi/u/hhallama/pics/kebabelain.jpg Commented Feb 25, 2015 at 11:25
  • 8
    As "caterpillar" has four syllables whereas "kebab", "dash" and "hyphen" have one or two, I think arguing for caterpillar-case is a losing battle Commented May 16, 2018 at 12:44
  • 3
    "caterpillar-case" is too long to be a case name, I think "worm-case" would be a better choice. :D Commented Jun 20, 2018 at 8:30
  • 12
    @DairaHopwood fully agree.. Pascal was also a living creature.
    – nawfal
    Commented Dec 26, 2018 at 12:30
25

This is the most famous case and It has many names

  • kebab-case: It's the name most adopted by official software
  • caterpillar-case
  • dash-case
  • hyphen-case or hyphenated-case
  • lisp-case
  • spinal-case
  • css-case
  • slug-case
  • friendly-url-case
22

As the character (-) is referred to as "hyphen" or "dash", it seems more natural to name this "dash-case", or "hyphen-case" (less frequently used).

As mentioned in Wikipedia, "kebab-case" is also used. Apparently (see answer) this is because the character would look like a skewer... It needs some imagination though.
Used in lodash lib for example.

Recently, "dash-case" was used by

1
  • 9
    The kebab case is referring to shish-kebab more than it is to döner kebab if that is any help.
    – Alper
    Commented Jun 27, 2017 at 9:05
17

Adding the correct link here Kebab Case

which is All lowercase with - separating words.

11

I've always called it, and heard it be called, 'dashcase.'

2
  • 23
    It shall forever be known as Dashy McDash Case
    – colllin
    Commented May 2, 2017 at 12:31
  • 17
    @colllin I think you mean dashy-mcdash-case ;)
    – siguy85
    Commented Aug 2, 2017 at 12:14
7

I've always known it as kebab-case.

On a funny note, I've heard people call it a SCREAM-KEBAB when all the letters are capitalized.

Kebab Case Warning

I've always liked kebab-case as it seems the most readable when you need whitespace. However, some programs interpret the dash as a minus sign, and it can cause problems as what you think is a name turns into a subtraction operation.

first-second  // first minus second?
ten-2 // ten minus two?

Also, some frameworks parse dashes in kebab cased property. For example, GitHub Pages uses Jekyll, and Jekyll parses any dashes it finds in an md file. For example, a file named 2020-1-2-homepage.md on GitHub Pages gets put into a folder structured as \2020\1\2\homepage.html when the site is compiled.

Snake_case vs kebab-case

A safer alternative to kebab-case is snake_case, or SCREAMING_SNAKE_CASE, as underscores cause less confusion when compared to a minus sign.

6

There is no standardized name.

Libraries like jquery and lodash refer it as kebab-case. So does Vuejs javascript framework. However, I am not sure whether it's safe to declare that it's referred as kebab-case in javascript world.

0
5

I'd simply say that it was hyphenated.

1
  • 9
    Hyphenated might be a good answer to an English question, but for code it's not specific enough. For example, in kebab-case all letters are lowercase.
    – rybo111
    Commented Jun 16, 2017 at 22:03
5

Worth to mention from abolish:

https://github.com/tpope/vim-abolish/blob/master/doc/abolish.txt#L152

dash-case or kebab-case

4

In Salesforce, It is referred as kebab-case. See below

https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.js_props_names

2

Here is a more recent discombobulation. Documentation everywhere in angular JS and Pluralsight courses and books on angular, all refer to kebab-case as snake-case, not differentiating between the two.

Its too bad caterpillar-case did not stick because snake_case and caterpillar-case are easily remembered and actually look like what they represent (if you have a good imagination).

1

My ECMAScript proposal for String.prototype.toKebabCase.

String.prototype.toKebabCase = function () {
  return this.valueOf().replace(/-/g, ' ').split('')
    .reduce((str, char) => char.toUpperCase() === char ?
      `${str} ${char}` :
      `${str}${char}`, ''
    ).replace(/ * /g, ' ').trim().replace(/ /g, '-').toLowerCase();
}
4
  • any response to the proposal?
    – nazreen
    Commented Jun 21, 2019 at 4:36
  • any response to your response? Commented Mar 25, 2020 at 6:45
  • 2
    his-idea-was-skewered
    – RobKohr
    Commented Jun 24, 2020 at 8:38
  • well it was more of a joke haha Commented Jul 20, 2020 at 9:39
1

This casing can also be called a "slug", and the process of turning a phrase into it "slugify".

https://hexdocs.pm/slugify/Slug.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.