kebab-case writes words in lowercase and joins them with hyphens: my-variable-name. The converter reads camelCase, PascalCase and snake_case as well as plain text: myVariableName becomes my-variable-name, HTTPServer becomes http-server and user_first_name becomes user-first-name.
Brand names, symbols and accented letters are the three places where the word split needs a human check.
How the converter splits text into kebab-case words
Eight things happen when text becomes kebab-case:
- Spaces, underscores and dots become hyphens. Each of them marks a word boundary, so user_first_name becomes user-first-name and version 2.5 becomes version-2-5.
- A capital after a lowercase letter starts a new word. That is how camelCase marks its words: myVariableName becomes my-variable-name. A capital after a digit starts a new word too.
- A run of capitals stays one word. HTTPServer becomes http-server, not h-t-t-p-server: only the last capital of the run, the one a lowercase letter follows, opens the next word.
- Every letter becomes lowercase. The hyphen already marks each word, so capitals carry nothing: SCREAMING_SNAKE_CASE becomes screaming-snake-case.
- Digits stay attached to their word. ABC123def becomes abc123def. A digit starts a word of its own only after a space or a symbol.
- Other symbols are removed. Between two words they leave a hyphen, so C++ & C# becomes c-c.
- Repeated and edge hyphens are trimmed. --dry-run becomes dry-run: the result never starts or ends with a hyphen and never doubles one.
- Apostrophes are dropped without splitting the word. Don't becomes dont, not don-t, because an apostrophe cannot be part of a CSS class name (CSS Syntax).
getHTTPResponseCode becomes get-http-response-code
SCREAMING_SNAKE_CASE becomes screaming-snake-case
Don't Stop: Café 2.5 becomes dont-stop-café-2-5
These rules read letters, not meaning, so a few kinds of text come out in a form worth reading before you use it.
Where the word split needs a human check
Three kinds of text need a second look: brand names with a capital inside, names made of symbols, and words with an apostrophe or an accent.
Brand names with an inner capital, like iPhone and OAuth
A capital inside a word reads as a word boundary, so iPhone 15 Pro becomes i-phone-15-pro and OAuth2Client becomes o-auth2-client. The JavaScript libraries lodash and change-case split iPhone the same way. If the name is a brand, join it by hand: iphone-15-pro.
Names made of symbols, like C++ and C#
Symbols that carry the meaning are lost: C++ and C# both become c, and C++ & C# becomes c-c. Spell such names out before you convert them – cpp, csharp.
Apostrophes and accented letters
An apostrophe inside a word is dropped and the word stays whole: Don't Stop becomes dont-stop. Accented letters are kept: Café Résumé becomes café-résumé, which is a valid CSS class name, because CSS identifiers accept letters such as é, ü and ß (CSS Syntax).
Package registries are stricter. An npm name cannot contain “non-URL-safe characters” (npm), a Debian package name allows only lowercase letters a–z, digits, plus and minus signs, and periods (Debian), and a Kubernetes name may “contain only lowercase alphanumeric characters or '-'” ( Kubernetes). For a package name, replace the accented letters by hand; the URL slug generator does that for you.
Where kebab-case is used
kebab-case is the format for names that a browser, a shell or a file system reads, rather than a programming language. MDN's glossary names the two best-known cases: CSS properties and HTML attributes “are in kebab case” (MDN).
CSS class names and custom properties
A class name such as product-cardhas the same shape as CSS's own property names, background-color and font-family (MDN). A custom property is “any property whose name starts with two dashes” (CSS Variables): the converter gives main-color, and you add the dashes to make --main-color. Unlike other properties, custom property names are case-sensitive, so lowercase everywhere keeps one name from becoming two.
One limit: a CSS identifier cannot start with a digit unless it is escaped (CSS Syntax). 2nd place becomes 2nd-place, which needs a letter in front before it works as a class name.
HTML data and ARIA attributes
A custom data attribute starts with data-and “contains no ASCII upper alphas” (HTML Standard), so dataUserId becomes data-user-id. ARIA attributes such as aria-label have the same shape (MDN). JavaScript reads the attribute data-user-id as dataset.userId: the hyphen is dropped and the letter after it becomes a capital (HTML Standard). Vue's style guide adds that in-DOM templates “must still use kebab-case”, because HTML ignores case (Vue).
Command-line flags
GNU long options “consist of -- followed by a name made of alphanumeric characters and dashes” (GNU C Library), as in --dry-run. POSIX itself describes only one-character options (POSIX). Dry Run becomes dry-run: the converter returns the name, and the two leading dashes are yours to add.
File, folder and package names
Package registries set the strictest rules. npm says: “New packages must not have uppercase letters in the name”, and a name can be at most 214 characters long (npm). PyPI compares names after every run of dots, hyphens and underscores is “replaced with a single - character” (PEP 503). Debian and Kubernetes accept lowercase letters, digits and hyphens (Debian, Kubernetes).
For file names, Google's style guide for its developer documentation says: “Use hyphens, not underscores, to separate words” (Google). Angular's style guide separates the words of a file name with hyphens (Angular), and Vue asks for single-file component names that are “always PascalCase or always kebab-case” (Vue).
Why most programming languages reject kebab-case names
Because in most languages the hyphen is the minus sign. JavaScript identifiers “can contain Unicode letters, $, _, and digits” (MDN), and Python names are built from letters, the underscore and digits (Python reference) – neither list has a hyphen. In JavaScript the -operator “subtracts the two operands” (MDN), so my-var reads as my minus var.
A few languages are the exception. Clojure symbols can contain a hyphen (Clojure), Raku allows one inside an identifier when a letter follows it (Raku), and Common Lisp names its own functions this way, as in MAKE-HASH-TABLE (Common Lisp HyperSpec) – hence another name for the format, lisp-case. Rust shows the usual workaround: Cargo builds the library name from the package name “with any dashes replaced with underscores” (Cargo), so the package my-crate is my_crate in code.
How kebab-case differs from snake_case, camelCase and a URL slug
snake_case joins the same lowercase words with underscores, for code where a hyphen is not allowed: the snake_case converter turns my-crate into my_crate. camelCase drops the separator and marks each word with a capital, which is how JavaScript names an HTML attribute; the camelCase converter turns data-user-id into dataUserId. A URL slug uses the same hyphens but follows URL rules: the URL Slug Generator keeps iPhone whole and turns café into cafe. Choose kebab-case when a browser, a shell or a file system reads the name.
Questions about kebab-case
What is kebab case?
Kebab case is a way of writing a name without spaces: the words are lowercase and joined with hyphens, as in my-variable-name. MDN's glossary describes it as writing phrases "where spaces are replaced with hyphens."
Why is it called kebab case?
MDN's glossary gives the reason: "The name comes from the similarity of the words to meat on a kebab skewer." The hyphens are the skewer and the words are the pieces on it.
What are other names for kebab-case?
dash-case is the main one: Angular's documentation uses that name, and the top-voted Stack Overflow answer on the question says the format "is known as dash-case or kebab-case." The same answer lists lisp-case and hyphen-case as rarer names. train-case is a different format: it keeps a capital on each word, as in Two-Words.
Is there an uppercase kebab-case?
Not in this converter: every letter comes out lowercase, so Two Words becomes two-words. A hyphenated name with a capital on each word, such as Two-Words, is called train-case in the change-case library.
How do I turn kebab-case back into words?
Replace the hyphens with spaces, then convert to title case: my blog post becomes My Blog Post. With the hyphens left in, the name is read as one hyphenated compound and comes out as My-Blog-Post.
Can I use kebab-case in a URL?
Yes: lowercase words joined with hyphens are what a URL slug looks like. A slug follows extra rules, though. Accented letters become plain ones and a brand name such as iPhone stays whole, so for a page address use the URL slug generator.