Skip to main content

Convert Text to kebab-case Online Convert text to kebab-case for CSS classes, URLs, and file names.

kebab-case Converter illustration
📝

kebab-case Converter

Convert text to kebab-case for CSS classes, URLs, and file names.

1

Paste Your Text

Type or paste text to convert to kebab-case.

2

Preview the kebab-case Output

See lowercase hyphenated output instantly.

3

Copy the Converted Text

Copy for CSS classes, URLs, or file names.

Loading tool...

What Is kebab-case Converter?

A kebab-case converter transforms text into kebab-case format, where all letters are lowercase and words are separated by hyphens. Developers who work with CSS, HTML, and JavaScript use it to convert camelCase or PascalCase names to a format compatible with their frameworks. One specific problem it solves is handling long strings of text that need to be converted to kebab case for use in URL slugs or npm package names.

The tool uses regular expressions to split words in the input string, replacing underscores, hyphens, and periods with spaces before converting them to lowercase and joining with hyphens. This process allows it to handle complex strings like "helloWorld" or "background-color-test", producing output like "hello-world" and "background-color-test".

What makes this tool different is its ability to process multiline input, splitting each line into words and then joining them back together with hyphens before returning the result. It acts as a kebab-case generator, allowing users to convert text to kebab-case online without having to write custom code or use a separate text editor. For example, if you paste "Hello World" and "backgroundColor" into the tool, it will output "hello-world" and "background-color", which can then be used directly in your code. The output is formatted with each line on a new line, making it easy to copy and paste into your project.

Why Use kebab-case Converter?

  • Standard for CSS class names and custom properties
  • Required format for URL slugs in most web frameworks
  • Used for npm package names and Git branch names
  • Most readable format for multi-word identifiers in web contexts
  • Handles conversion from any input format

Common Use Cases

CSS Classes

Format class names following BEM or standard CSS naming conventions.

URL Slugs

Create SEO-friendly URL paths from page titles or content headings.

npm Packages

Apply npm's required naming convention for published packages.

File Naming

Name files in kebab-case for Angular, Vue, and other component-based frameworks.

Technical Guide

kebab-case conversion follows the same word-splitting algorithm as snake_case but joins words with hyphens instead of underscores. Input is split on whitespace, underscores, dots, existing hyphens, and case transitions. All words are converted to lowercase and joined with single hyphens. Consecutive hyphens are collapsed, and leading/trailing hyphens are removed. The algorithm correctly handles camelCase input ("backgroundColor" → "background-color"), PascalCase ("PageTitle" → "page-title"), and mixed formats. Note that kebab-case identifiers cannot be used directly as variable names in most programming languages because the hyphen is the subtraction operator.

Tips & Best Practices

  • 1
    CSS properties are natively kebab-case: background-color, font-size, border-radius
  • 2
    BEM methodology uses kebab-case with double hyphens: block__element--modifier
  • 3
    kebab-case URLs are preferred for SEO over underscores or camelCase
  • 4
    In JavaScript, access kebab-case properties with bracket notation: obj["my-prop"]
  • 5
    Angular uses kebab-case for component selectors (app-user-profile)

Related Tools

Frequently Asked Questions

Q What is kebab-case?
kebab-case uses all lowercase letters with hyphens between words: my-variable, page-title, nav-bar-item.
Q Why can't I use kebab-case for JavaScript variables?
Hyphens are interpreted as the minus operator in JavaScript. Use bracket notation (obj["my-key"]) or camelCase instead.
Q Is kebab-case better than snake_case for URLs?
Google treats hyphens as word separators but not underscores, so kebab-case is preferred for SEO in URLs.
Q How do CSS custom properties use kebab-case?
CSS custom properties (variables) use kebab-case with a -- prefix: --primary-color, --font-size-large.
Q How does BEM relate to kebab-case?
BEM (Block Element Modifier) uses kebab-case as its base, with __ for elements and -- for modifiers.

About This Tool

kebab-case Converter is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.