What kebab-case is
kebab-case uses hyphens where the spaces would be and keeps every letter lowercase:
My Blog Post Titlebecomesmy-blog-post-titlebackgroundColorbecomesbackground-coloruser_profile_cardbecomesuser-profile-card
How the converter works
The tool finds the words on each line, lowercases them and joins them with hyphens. Words can be separated by spaces, underscores, dots or slashes, or by capital letters as in camelCase and PascalCase. Punctuation is removed. Each line is converted separately, so you can paste a list of titles or class names and get a matching list back.
| Input | Output |
|---|---|
| My First Blog Post! | my-first-blog-post |
| backgroundColor | background-color |
| user_profile_card | user-profile-card |
| ProductListItem | product-list-item |
| 10 Tips for Better Sleep | 10-tips-for-better-sleep |
Where kebab-case is used
- URLs:
example.com/blog/my-first-post - CSS: class names such as
.nav-itemand properties such asfont-size - HTML: attributes such as
data-user-idand custom element names such as<user-card> - File and folder names: especially in web projects
- npm packages: package names must be lowercase, and hyphens are the usual separator
- Command line flags:
--dry-run,--no-cache
kebab-case for URL slugs
A slug is the readable part of a web address that identifies a page. Good slugs are short, lowercase and hyphenated. Paste your page title here to get a starting point, then trim it:
- Convert the title: “10 Tips for Better Sleep” becomes
10-tips-for-better-sleep. - Remove filler words if the slug is long:
tips-better-sleep. - Keep the main keyword of the page in the slug.
Lowercase matters because many web servers treat /My-Page and /my-page as two different addresses.
Compared with other styles
| Style | Example | Works in code? |
|---|---|---|
| kebab-case | user-first-name | No, hyphen means minus |
| snake_case | user_first_name | Yes |
| camelCase | userFirstName | Yes |
Need one of the others? Try the snake case converter or the camel case converter.