Menu

Kebab Case Converter

Paste words, variable names or headings and each line becomes lowercase words joined by hyphens, so "backgroundColor" turns into "background-color". Switch the separator to get dot.case instead.

0 words 0 characters 0 lines

Separator

Continue with this text: camelCasesnake_caseURL slug

Your text stays in your browser: nothing is uploaded or stored on a server.

How to use the kebab case converter

  1. Type or paste your text into Your text, or click Example to load four sample names in different styles. Open file reads a plain-text file such as a .txt or .csv.
  2. Choose a Separator: kebab-case (hyphens) is the default; dot.case joins the same words with periods.
  3. The Result box updates as you type. Each input line gives one output line, so a list of 200 names comes back as 200 converted names in the same order.
  4. Click Copy or Download .txt, or Use as input to keep working on the result. The links under the result send it on to camelCase, snake_case or the URL slug tool.

How the tool finds the words

The converter works one line at a time. On each line it first marks where a new word starts inside a name, then splits at everything that is not a letter or a digit, lowercases each word and joins them with the separator. The rules:

Rule Before After
Spaces, underscores, dots and existing hyphens separate words nav_menu_item nav-menu-item
A lowercase letter or digit followed by a capital starts a new word backgroundColor background-color
In a run of capitals, the last capital before a lowercase letter starts a new word XMLHttpRequest xml-http-request
All-caps names are split at their underscores MAX_RETRY_COUNT max-retry-count
Digits stay with the word before them HTML5Parser html5-parser
One lowercase letter followed only by capitals is one word iOS app ios-app
Capitals before a lowercase letter and a digit stay together IPv6 address ipv6-address
Apostrophes inside a word are dropped, not treated as a break Don't Stop dont-stop
A single capital before an apostrophe stays with the next word O'Brien obrien
Repeated or mixed separators collapse to one a--b__c a-b-c
Spaces at the start and end are dropped leading and trailing leading-and-trailing
Punctuation, symbols and emoji are removed How to Bake Bread! how-to-bake-bread

The acronym rule is what makes names such as getHTTPResponseCode come out as get-http-response-code rather than get-h-t-t-p-response-code or gethttp-response-code. A whole word in capitals with no lowercase letters, such as ABC, stays one word: abc.

Edge cases worth knowing

Because the tool treats a capital after a lowercase letter or digit as a new word, a few names split in places you might not expect. These outputs come straight from the tool:

Before After Why
iPhone 15 Pro i-phone-15-pro The capital P after a lowercase i starts a word.
OAuth2Token o-auth2-token The O is read as a one-letter word before Auth.
H2O level h2-o-level The capital O after a digit starts a word.
price $9.99 price-9-99 The decimal point separates the digits.
file-name.txt file-name-txt File extensions lose their dot.

If one of these matters, fix the source text first (write iphone instead of iPhone) or correct the few lines by hand afterwards. For titles that should become web addresses, use the URL slug generator, which also removes accents.

Other behavior:

  • Accents and other alphabets are kept and lowercased: Café Crème Brûlée becomes café-crème-brûlée, Ünïcödé Straße becomes ünïcödé-straße, and 東京 タワー becomes 東京-タワー. To get plain ASCII letters, run the text through remove accents first.
  • Empty lines stay empty, and a line with only spaces becomes empty. Windows line endings (CRLF) are written back as plain line feeds.
  • A paragraph is one line, so a long sentence becomes one long hyphenated string. Put each name on its own line.

kebab-case or dot.case

The Separator option changes only the character placed between the words; the splitting and lowercasing are the same.

Before kebab-case dot.case
Primary Button Large primary-button-large primary.button.large
backgroundColor background-color background.color
nav_menu_item nav-menu-item nav.menu.item
XMLHttpRequest xml-http-request xml.http.request

Dot case is common for configuration keys and translation keys, such as user.first.name in a settings or language file. Converting user.first.name with the hyphen separator gives user-first-name, so the tool also works for going from dot case back to kebab case.

Where kebab case is used

According to MDN, kebab case is the convention for CSS property names such as background-color and font-family, and for HTML attributes such as aria-label and data-*. Typical jobs for this converter:

  • CSS class names and custom properties. Turning a list of design token names like mainBgColor into main-bg-color, then adding the -- prefix custom properties need (--main-bg-color). MDN notes that custom property names are case sensitive, so --my-color and --My-color are different properties; lowercasing everything avoids that mistake.
  • data attributes. In JavaScript, element.dataset.userId reads the attribute data-user-id: the browser converts the part after data- from kebab case to camelCase. Converting userId here gives user-id; add data- in front for the attribute name. MDN advises against a digit right after a hyphen (data-test-1), because dataset will not recognize it.
  • File and folder names for components, pages and images, when a project’s convention is lowercase names with hyphens.
  • URL paths. Google’s Search Central documentation recommends hyphens rather than underscores to separate words in URLs. For page addresses, though, the URL slug generator is the better choice: it removes accents and apostrophes and can shorten long slugs.

Kebab case, snake case, camel case and Pascal case

All four write a multi-word name without spaces; they differ in the separator and the capitals. The cheat sheet beside the tool shows one name in each.

  • kebab-case: lowercase, hyphens. CSS, HTML attributes, URLs.
  • snake_case: lowercase, underscores. Function and variable names in Python (PEP 8), and often database column names. Use the snake case converter.
  • camelCase: no separator, each word after the first capitalized. The form JavaScript’s dataset uses, turning data-user-id into userId. Use the camel case converter.
  • PascalCase: like camelCase, but the first word is capitalized too. Class names in Python (PEP 8 calls it CapWords), and often types and UI components. Use the Pascal case converter.

Kebab case cannot be used for variable names in most languages, because a hyphen is read as a minus sign. The guide to camelCase vs snake_case vs kebab-case compares the three conventions in more detail.

Questions

What is kebab case?

Kebab case writes a phrase without spaces, with words in lowercase and joined by hyphens, as in "main-bg-color". The name comes from the words looking like pieces of meat on a skewer.

What is the difference between kebab case and snake case?

Only the separator. Kebab case joins words with hyphens (user-profile-photo) and snake case with underscores (user_profile_photo). Kebab case is used in CSS, HTML attributes and URLs; snake case is what Python's style guide, PEP 8, uses for function and variable names, where a hyphen would be read as a minus sign. The snake case converter does the other one.

What is the difference between kebab case and camel case?

Camel case removes the separators and marks each new word with a capital letter (userProfilePhoto); kebab case keeps everything lowercase and puts a hyphen between words (user-profile-photo). In JavaScript, the browser converts an HTML attribute such as data-user-id to dataset.userId. Use the camel case converter to go the other way.

What is the difference between kebab case and Pascal case?

Pascal case capitalizes every word, including the first, and uses no separator (UserProfilePhoto); Python's PEP 8 calls it CapWords and uses it for class names. Kebab case is all lowercase with hyphens. A component named UserProfilePhoto in this tool becomes user-profile-photo.

Can I use kebab case for variable names?

Not in most programming languages. As MDN notes, many languages read the hyphen as subtraction, so user-name means "user minus name". Kebab case is used where names are strings or markup, such as CSS classes, HTML attributes, file names and URLs.

Does the converter keep accents and other alphabets?

Yes. Letters from any alphabet are kept and lowercased, so "Café Crème" becomes café-crème. For a URL slug with plain ASCII letters, use the URL slug generator, which removes accents first.

Is my text sent anywhere?

No. The conversion runs in your browser as you type, and the text is not uploaded or stored on a server.