Convert text to kebab-case

Type “Getting Started Guide” to get getting-started-guide, live as you type. kebab-case is the convention for URLs, CSS classes and custom HTML attributes: search engines treat hyphens as word separators. It cannot be a variable name in most languages, because the hyphen parses as subtraction. Conversion stays in this tab.

camelCase

gettingStartedGuide

PascalCase

GettingStartedGuide

snake_case

getting_started_guide

kebab-case

getting-started-guide

CONSTANT_CASE

GETTING_STARTED_GUIDE

Converted as you typeNothing leaves this tab

Runs in this tab · nothing is uploaded · Verify in 10 seconds →

What this does

kebab-case lowercases words and joins them with hyphens: “Getting Started Guide” becomes getting-started-guide, and camelCase input like pageHeaderTitle becomes page-header-title. Type below and read the kebab-case row, it updates live.

kebab-case's home turf is the one place the other conventions cannot go: URLs, where search engines treat the hyphen as a word separator but the underscore as a word joiner, ten-tips indexes as two words, ten_tips as one token. The cost is symmetrical with snake_case: on our corpus's 244 unique keys, kebab-case averages 7.5 characters against camelCase's 7.2, one hyphen per word boundary.

Where kebab-case is the convention

kebab-case (also called lisp-case or dash-case) is the separator that survives case-insensitive contexts. HTML and CSS treat class names and attribute names as case-insensitive, so capitals cannot carry a word boundary; a hyphen can. Search engines tokenise a hyphen in a path and usually swallow an underscore.

  • CSS. Class selectors and custom properties are kebab-case: .page-header, .is-active, --main-color, --font-size. BEM modifiers (block__element--modifier) already mix underscores and hyphens; feeding that string through this converter flattens the extra underscores into extra hyphens, so treat finished BEM as output, not as input.
  • HTML attributes and custom elements. data-* and aria-* names are specified in kebab-case (data-user-id, aria-label, aria-labelledby). Custom element tag names must contain a hyphen (<user-card>, <app-shell>). Ordinary attributes that browsers ship (tabindex, colspan) are single tokens; do not invent camelCase versions of them.
  • URLs, slugs and file names. /getting-started-guide indexes as three words; /getting_started_guide tends to index as one. Hyphens also stay visible when a link is underlined, which an underscore does not. Static-site file names and npm package name suffixes follow the same pattern.
  • CLI flags and Lisp. GNU and POSIX long options are kebab-case: --dry-run, --output-file, --export-csv. Add the leading -- yourself; it is not part of the identifier. Clojure and other Lisps use kebab-case for function names because a hyphen is legal in those symbols. webpack, Vite and many JSON config keys follow the same spelling.
  • Not kebab-case. JavaScript, Java, Kotlin, C# and Swift members are camelCase. Python (PEP 8), Ruby, Rust and SQL are snake_case. A hyphen in any of those languages is subtraction or a syntax error. Convert at the HTML, CSS, URL or flag boundary, not inside the function body.

kebab-case versus a URL slug

This row reuses the snake_case splitter, then turns every underscore into a hyphen. It lowercases, splits on an ASCII lowercase-or-digit followed by an uppercase letter, and replaces spaces and underscores. That is the whole job. pageHeaderTitle becomes page-header-title, data_user_id becomes data-user-id, aria-label stays aria-label, and “Getting Started Guide” becomes getting-started-guide.

A slug generator goes further: Unicode NFKD normalisation, stripping combining marks (é becomes e), mapping symbols such as & to words, and dropping everything outside a–z, 0–9 and the separator. This converter does none of that. café_menu becomes café-menu, 日本語_label becomes 日本語-label, and user.accountId becomes user.account-id. If the output has to be a public path, switch to the Slug Generator.

The same acronym and digit rules as snake_case apply: HTTPRequest becomes httprequest, parseJSON becomes parse-json, utf8String becomes utf8-string, v2APIClient becomes v2-apiclient, user2fa stays user2fa. Consecutive underscores become consecutive hyphens (user__account becomes user--account). A run of hyphens in the input is first collapsed by the snake_case pass, so user--account typed as input becomes user-account. Leading spaces become a leading hyphen. CSS custom properties typed as --main-color come out -main-color (one leading hyphen), which is not a valid custom property: keep the extra dash yourself or type main-color and add -- in the stylesheet.

HTTP header field names are kebab-case historically (Content-Type, Accept-Language) and lowercase kebab in HTTP/2 (content-type). Kubernetes labels prefer kebab-case or DNS subdomains. Next.js app-router folders, Eleventy permalinks and most static-site path segments are kebab-case. npm package names allow hyphens and forbid capitals. Stylelint’s selector-class-pattern and most design-system linters reject camelCase class names. None of those systems want camelCase in a public path.

Worth typing: onSubmit becomes on-submit, createdAt becomes created-at, getObjectOr404 becomes get-object-or-404, X-Request-Id becomes x-request-id, XMLHttpRequest becomes xmlhttp-request. HTTPRequest still collapses to httprequest. A finished BEM class such as card__title--large becomes card--title--large, which is why BEM should not go through this row.

When it goes wrong

kebab-case cannot be a variable name in most languages, because the hyphen parses as subtraction (page-header is page minus header), so if code is the destination you wanted the camelCase or snake_case row. This row is identifier conversion, not slug generation: accents stay (café_menu becomes café-menu), symbols stay, and dots stay (user.accountId becomes user.account-id). The Slug Generator is the tool that strips diacritics, maps “&” to “and”, and drops everything outside a–z, 0–9 and the separator. All-caps acronyms without a hump collapse: HTTPRequest becomes httprequest, not http-request.

When to use this

Use kebab-case for CSS classes, custom properties, HTML attributes, custom element names, public URL paths, web file names and GNU-style CLI flags. Use the Slug Generator instead when the input is a human title that still contains accents or punctuation. Use camelCase or snake_case when the destination is a programming identifier.

This page is a focused view of theCase Converter, which has the full set of options.

Frequently asked questions

Why kebab-case for URLs instead of underscores?

Search engines treat hyphens as word separators but tend to treat underscores as joiners, so ten-tips reads as two words while ten_tips reads as one. Hyphens also stay visible inside underlined links. That is why public paths use getting-started-guide, not getting_started_guide.

Can kebab-case be used for variable names?

Not in JavaScript, Python, Java, C, Rust or SQL: the hyphen parses as subtraction (page-header is page minus header). It belongs in URLs, file names, CSS and HTML. Clojure is the common exception, because a hyphen is legal in a Lisp symbol.

Is kebab-case the same as a URL slug?

No. This row only changes separators and capitalisation. Accents, dots and symbols stay, so café_menu becomes café-menu. The Slug Generator also strips diacritics and punctuation and would emit cafe-menu. Use that for a title that will become a public path.

Why do CSS and HTML use kebab-case?

Class selectors and attribute names are case-insensitive in HTML and CSS, so capitals cannot mark a word boundary. Hyphens can. Custom properties (--main-color) and data-* / aria-* attributes are specified that way. Browsers will accept data-userId, but every linter and every tutorial writes data-user-id.

Do CLI flags use kebab-case?

Long options on GNU-style tools do: --dry-run, --export-csv. Paste exportCsv or export_csv to get export-csv, then add the leading -- yourself. Short flags (-n, -o) are single letters and do not go through a case converter.