563

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 url's.

Fez Vrasta
  • 11,462
  • 19
  • 73
  • 135
lms
  • 14,269
  • 12
  • 64
  • 113
  • 14
    @CatPlusPlus Lisp uses this-case, and because Google treats a `-` as a space, almost every SEO friendly URL uses it too. – lms Jun 30 '12 at 10:37
  • @lms: URLs are irrelevant to programming languages. And I said "most", I know there are languages that allow that, but they're a minority. – Cat Plus Plus Jun 30 '12 at 11:28
  • 26
    @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 Nov 08 '14 at 06:55
  • 4
    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 Mar 29 '15 at 21:15
  • 1
    What about UPPERCASE-WITH-DASHES? Admittedly rare today, best name I’m heard is COBOL-CASE, which is accurate, say at [UnderscoreVersusCapitalAndLowerCaseVariableNaming](http://c2.com/cgi/wiki?UnderscoreVersusCapitalAndLowerCaseVariableNaming) – Nils von Barth Aug 14 '15 at 05:08
  • 1
    Also -- it's not "UpperCamelCase" -- it's "TitleCase". – BrainSlugs83 Oct 14 '15 at 19:27
  • 2
    Asking "Is separating words with hyphens good or bad?" would be subjective. Asking for what it's called isn't. Nor would "What's the most common capitalisation style of Ruby methods?", for what it's worth. – Andrew Grimm Jun 20 '16 at 00:19
  • 4
    I'm voting to close this question as off-topic because [you should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page.](https://stackoverflow.com/help/dont-ask) – EJoshuaS - Reinstate Monica May 24 '19 at 19:03
  • GitLab is [joining the cause](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29169/diffs#3e7726e8f34cd0cb5a1dbcd522cb3bfeb82d0795_118_146) for `kebab-case` now :) – ddavison Jun 05 '19 at 00:21
  • I call it _anything-but-kebab-case-case_. – Sнаđошƒаӽ Jul 28 '19 at 07:17
  • By the way, there is also screaming snake case, `SOME_SYMBOL` useful for constants in many languages. – Alper Aug 26 '19 at 14:23

15 Answers15

490

There isn't really a standard name for this case convention, and there is disagreement over what it should be called.

That said, as of 2019, there is a strong case to be made that kebab-case is winning:

https://trends.google.com/trends/explore?date=all&q=kebab-case,spinal-case,lisp-case,dash-case,caterpillar-case

spinal-case is a distant second, and no other terms have any traction at all.

Additionally, kebab-case has entered the lexicon of several javascript code libraries, e.g.:

However, there are still other terms that people use. Lisp has used this convention for decades as described in this Wikipedia entry, so some people have described it as lisp-case. Some other forms I've seen include caterpillar-case, dash-case, and hyphen-case, but none of these is standard.

So the answer to your question is: No, there isn't a single widely-accepted name for this case convention analogous to snake_case or camelCase, which are widely-accepted.

Ben Lee
  • 50,019
  • 12
  • 118
  • 142
  • 135
    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 Jul 28 '14 at 09:01
  • Let me rephrase: linking an easy to vandalize website as source isn't a clever idea. Of course in this case, "vandalism" is hard to define - the linked wiki page does not have any good references to verify either version. In wikipedia terms, both spinal-case and kebab-case are as good as original research. – dequis Jul 29 '14 at 16:38
  • Also just to clear any possible misunderstandings: I was not aware the kebab-case edit was done a few days ago, and I am not involved in that at all. – dequis Jul 29 '14 at 16:39
  • 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. – Robert Tupelo-Schneck Nov 03 '14 at 06:38
  • 7
    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. – Robert Tupelo-Schneck Nov 03 '14 at 06:40
  • @BenLee as much as I love spinal-case, it looks like it might actually be called lisp-case. See this [wikipedia post](http://en.wikipedia.org/wiki/Naming_convention_(programming)#Lisp) and this answer on [Programmer Stack Exchange](http://programmers.stackexchange.com/a/104472) and the second reply on that answer. – tsiege Dec 23 '14 at 15:03
  • 3
    @Tsiege Yeah I actually agree. I updated my answer to reflect all the possibilities (putting lisp-case first), and explained how none of them are really standard, all of them relatively new coinings, and how there is currently disagreement over which should be standard. – Ben Lee Dec 23 '14 at 23:53
  • 12
    I like "catipillar-case" since it's squished and then long, and keeps with the animal theme – RenaissanceProgrammer Jan 29 '16 at 04:40
  • 3
    I don't get the idea behind "kebab-case". If you say "sausage-case", yeah, I get it. But "kebab-case"??? Anyway, I use "dash-case". – Florian F Jul 29 '16 at 17:01
  • 4
    'kebab-case' FTW! – clusterBuddy Sep 27 '16 at 10:43
  • 61
    kebab-case-because it-looks-like-the-words-are skewered-on-a-kebab – Aaron_H Dec 16 '16 at 05:10
  • 2
    CSS-case? http://stackoverflow.com/questions/7560813/why-are-dashes-preferred-for-css-selectors-html-attributes – Manu Mar 08 '17 at 13:49
  • 3
    The kebab case is referring to shish kebab (vegetables and meat intermittent on a small skewer) more than it is to the only meat döner kebab that you see everywhere. – Alper Jun 27 '17 at 09:09
  • 1
    @alper: I, too, feel like I see döner kebab everywhere, but I spend at least half of my time in the Netherlands and Australia. ☺ It's pretty unknown in most parts of the US, though, and we must take care not to offend the Americans by referring to anything that's different from their little media bubble (date format, gallons/pints/inches/calories, Fahrenheit, proprietary mobile networks, weird spellings, etc.) – Michael Scheper Jul 17 '17 at 16:53
  • @jv110 do you have a source for that? from my research (a couple years ago when i wrote this answer) there was no source suggesting a widespread use of any of these – Ben Lee Jan 17 '18 at 22:52
  • 1
    @BenLee I'm not sure how I would back up my claim, I know it's widespread because out of all the times I saw anyone talking about it, most were using "kebab-case". Plus, it's the only name that makes sense in this context, since it's pretty much a joke, and the programming community (this part of it, at least) loves jokes. GNU is more than proof of that. – jv110 Jan 18 '18 at 02:52
  • 1
    Dammit .. I like both kebab case and caterpillar case. Especially caterpillar case because it's so cute and visual. – a20 Oct 28 '18 at 03:17
  • 1
    Thank you for the tip on kebab-case; coming from the US, it makes sense to me, as the shish kebab is quite popular here. It's a shame though that skewer-case isn't the winning name, because not all regions of the world cook kebabs on a skewer (https://en.wikipedia.org/wiki/Kebab). – Paul Brannan Jun 12 '19 at 14:47
  • 1
    it's 2019 now and kebab-case is quite widely understood – nxmohamad Jun 21 '19 at 04:35
  • 1
    Yes, I put right at the very top of the answer that kebab-case is currently the winning candidate – Ben Lee Jun 24 '19 at 18:32
  • I so want this to be not called _kebab-case_ widespread. I would rather say _words-separated-with-dashes-case_, if I ever have to call it a _case_. I mean c'mon guys, why should this even be called a _case_ in the first place??? If anything, I might even call it _lisp-case_, but _kebab-case_??? Never. – Sнаđошƒаӽ Jul 28 '19 at 07:14
  • @dequis Should we call this a Wikipedia circular reference? Haha. – Robert Molina Mar 31 '20 at 16:42
  • skeleton case... definitely – Sandburg Dec 11 '20 at 11:23
487

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

mikemaccana
  • 81,787
  • 73
  • 317
  • 396
jwfearn
  • 26,394
  • 26
  • 89
  • 117
  • 202
    Here's [a reference](http://stackoverflow.com/questions/11273282/whats-the-name-for-snake-case-with-dashes/12273101#12273101), that makes it official ;) – Andreas Sep 21 '12 at 16:45
  • 13
    Here's another reference: https://github.com/qerub/camel-snake-kebab ;) – qerub Nov 06 '12 at 19:49
  • 11
    The recursion in the reference means it's that much more Lisp-like. – Michael Della Bitta Jan 11 '13 at 20:59
  • 145
    I upvoted this answer not because I believe it's the right one, but because I want it to be the right one. – Jason Swett Jan 20 '14 at 23:10
  • 4
    I hope no human is stupid enough to get kebab-case confused with case subtracted from kebab. – NARKOZ May 24 '14 at 05:48
  • 45
    I love the [citogenesis](https://xkcd.com/978/) going on here. This answer links to [lodash](https://lodash.com/docs#kebabCase) which links to [wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) which links to this answer! – gilly3 Jun 05 '15 at 18:20
  • 1
    Completing another loop: [http://en.wikipedia.org/wiki/citogenesis](http://en.wikipedia.org/wiki/citogenesis) – jwfearn Jun 05 '15 at 18:24
  • 2
    Hey, who doesn't love camel-flavoured kebab? https://github.com/Alhadis/Snippets/blob/master/js/utils.js#L510 –  Jun 23 '15 at 11:13
  • 4
    Congrats, this appears to be the earliest use of the term "kebab-case", and thus perhaps the origin! I've updated Wikipedia to make it clear that this is a non-standard term, but appears to be gaining currency: https://en.wikipedia.org/w/index.php?title=Naming_convention_(programming)&oldid=675864802 For example, no usenet uses before 2015: https://groups.google.com/forum/#!search/%22kebab$20case%22$20before$3A2014$2F01$2F01 ...but now has appeared in print (Living Clojure (2015), Carin Meier, p. 91)! – Nils von Barth Aug 13 '15 at 05:18
  • 1
    :) Dashes (--) are made of two hyphens (-). I would say kebab case represents hyphenated name sequences, but dashed would be insane a--big--name--with--emphasis--you--cannot--ignore... let's call it Drama-Case. – Rob_vH Sep 16 '15 at 19:05
  • 1
    Also there is another common variant, the SCREAMING_SNAKE_CASE – PabloQ Oct 02 '15 at 06:25
  • 2
    Just because it looks like a constant to my C-trained eyes, I'd call that CONST_CASE. Snakes don't scream. – Dan Nov 27 '15 at 16:00
  • For those who are wondering: [Why the hell kebab?](http://i.imgur.com/4liLpYA.png) – MaciejLisCK Jun 30 '16 at 13:58
  • @MaciejLisCK That's not a kebab... it's a skewer. So now we find out that it should have been called `skewer-case`? – Fez Vrasta Sep 30 '16 at 13:19
  • AngularJS docs call it this as well. Usage creates and defines terms, not dictionaries. https://angular.io/docs/ts/latest/tutorial/toh-pt3.html – David Betz Oct 19 '16 at 21:01
  • 3
    Microsoft doc's point here ;) https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-components – Jeremy Lakeman Mar 09 '17 at 01:33
  • 1
    For anyone checking the circular reference from [here](https://stackoverflow.com/a/12273101/507738) to [lodash](https://lodash.com/docs#kebabCase) to [Wiki](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) to [here](https://stackoverflow.com/a/12273101/507738) — it has been broken as of 1 January 2016, caused by an [edit to the Wiki article](https://en.wikipedia.org/w/index.php?title=Letter_case&type=revision&diff=697686060&oldid=696389739). Too bad, I love [recursion](https://stackoverflow.com/questions/11273282/whats-the-name-for-hyphen-separated-case#comment84525962_12273101). – MC Emperor Feb 13 '18 at 08:55
  • 1
    Shouldn't it be Shish Case? Otherwise we may confuse it for Durum Case or Doner Case, which are totally different. We must be precise. – niico Mar 06 '19 at 14:12
  • https://techdebug.com/blog/2008/04/19/wikipedia-article-creates-circular-references/ – yunzen Apr 15 '19 at 10:22
  • SO answer as the canon source for a term. /me likes! – Tanveer Badar Jan 14 '20 at 08:08
37

It's also sometimes known as caterpillar-case

tim_yates
  • 154,107
  • 23
  • 313
  • 320
  • 65
    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. – Daira Hopwood Jan 11 '15 at 02:02
  • 27
    @DairaHopwood http://www.cs.helsinki.fi/u/hhallama/pics/kebabelain.jpg – mikemaccana Feb 25 '15 at 11:25
  • 5
    As "caterpillar" has four syllables whereas "kebab", "dash" and "hyphen" have one or two, I think arguing for caterpillar-case is a losing battle – Ninjakannon May 16 '18 at 12:44
  • 1
    "caterpillar-case" is too long to be a case name, I think "worm-case" would be a better choice. :D – Bahattin Ungormus Jun 20 '18 at 08:30
  • 1
    I like caterpillar-case ! If there had to be a worm-case I think it would be all lowercase attached words ie: somethinglikethisisdifficulttoread – Ki Jéy Dec 10 '18 at 10:43
  • 9
    @DairaHopwood fully agree.. Pascal was also a living creature. – nawfal Dec 26 '18 at 12:30
16

Adding the correct link here Kebab Case

which is All lowercase with - separating words.

user666
  • 1,016
  • 11
  • 19
12

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

Guillaume Husta
  • 3,125
  • 25
  • 39
  • 6
    The kebab case is referring to shish-kebab more than it is to döner kebab if that is any help. – Alper Jun 27 '17 at 09:05
12

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
amin_nejad
  • 570
  • 5
  • 18
Shadi Namrouti
  • 7,498
  • 1
  • 38
  • 47
10

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

Mike Campbell
  • 7,663
  • 2
  • 34
  • 50
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.

Gaurang Patel
  • 379
  • 4
  • 10
5

I'd simply say that it was hyphenated.

Dirk Vollmar
  • 161,833
  • 52
  • 243
  • 303
Jem Marsh
  • 79
  • 1
  • 3
  • 8
    *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 Jun 16 '17 at 22:03
4

Worth to mention from abolish:

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

dash-case or kebab-case

albfan
  • 10,988
  • 2
  • 49
  • 74
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).

2

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.

Cameron McKenzie
  • 2,640
  • 23
  • 19
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();
}
Christoph Bühler
  • 2,343
  • 1
  • 21
  • 38
0

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

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

MgSam
  • 10,330
  • 16
  • 59
  • 85