Skip to content

Kebab case

FormatExperimentalLimited support. Verify anything critical.

Kebab case (also known as dash-case, lisp-case, or spinal-case) is a text formatting convention that splits input phrases on spaces, underscores, and capital-letter boundaries—including screaming-snake input such as HELLO_WORLD—then lowercases every token and joins them together using hyphens. This format is heavily relied upon in web development for generating readable, predictable strings. Most importantly, this conversion tool prioritizes your privacy by running entirely locally in your web browser; the text you paste is securely processed on your own device and is never uploaded to or stored on any external server.

Skip to the tool

This tool processes text on your device. The text is not uploaded.

  • Separators are spaces, hyphens, and underscores.
  • Unicode letters are kept but not linguistically cased.

How to use Kebab case

What is Kebab case?

Kebab case (also known as dash-case, lisp-case, or spinal-case) is a text formatting convention that splits input phrases on spaces, underscores, and capital-letter boundaries—including screaming-snake input such as HELLO_WORLD—then lowercases every token and joins them together using hyphens. This format is heavily relied upon in web development for generating readable, predictable strings. Most importantly, this conversion tool prioritizes your privacy by running entirely locally in your web browser; the text you paste is securely processed on your own device and is never uploaded to or stored on any external server.

Practical developer use cases

Kebab-case is a fundamental naming convention across modern engineering stacks. Common use cases include:

  • Web URLs and Routing: Constructing clean, RESTful endpoint paths (e.g., /api/v1/user-profiles/). Unlike camelCase or snake_case, hyphens are treated as standard space delimiters by search engine indexers, drastically improving SEO and keyword parsing.
  • CSS Selectors and HTML Attributes: Standardizing class names (.button-primary, .grid-container) and custom data attributes (data-user-id, aria-labelledby) for readability and consistency.
  • Package Management: Naming published dependencies and libraries in ecosystems like NPM (e.g., react-dom, lodash-es), where uppercase characters are often forbidden.
  • Cloud and Infrastructure: Tagging and naming Kubernetes pods, namespaces, AWS resources, and Helm charts. These systems frequently enforce strict DNS-1123 compliance, mandating lowercase alphanumeric characters and hyphens.
Best practices

When integrating kebab-case into your workflows, keep these best practices in mind:

  • Understand Tokenization Boundaries: Be aware of how acronyms and uppercase sequences are handled. A robust tokenizer safely splits acronym boundaries (e.g., transforming XMLHttp into xml-http), guaranteeing consistent lowercase hyphenated outputs.
  • Internationalization Differences: While kebab-case preserves base Unicode characters (lowercasing them appropriately), it does not perform ASCII transliteration. If your application requires strict ASCII strings—such as for highly restricted legacy systems—you should use a dedicated Slugify tool instead.
  • Avoid Trailing Hyphens: Ensure your text manipulation pipelines trim leading or trailing hyphens after removing punctuation or special characters.
Security considerations
  • Zero Data Leakage: Because this utility performs all string manipulations strictly on the client side, sensitive strings such as proprietary API endpoints, internal microservice names, or user data can be safely converted without risk of network interception.
  • Injection Attacks: While kebab-cased strings are inherently URL-safe and typically exclude malicious HTML characters, you must always sanitize user-generated inputs before rendering them directly into the DOM or injecting them into database queries to prevent Cross-Site Scripting (XSS).
Code examples

Here are implementations for converting standard strings to kebab-case in popular programming languages:

JavaScript / TypeScript

function toKebabCase(input: string): string {
  return input
    .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
    .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2")
    .replace(/[_.\s]+/g, "-")
    .trim()
    .toLowerCase()
    .replace(/^-+|-+$/g, "");
}

Python 3

import re

def to_kebab_case(text: str) -> str:
    # Insert spaces between lowercase and uppercase boundaries
    text = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", text)
    # Split by spaces, underscores, or existing hyphens
    words = re.split(r"[-_\s]+", text)
    # Join with hyphens and lowercase
    return "-".join(word.lower() for word in words if word)

How it works

  1. Enter what you haveType or pick your text. Nothing is submitted anywhere.
  2. It runs in this tabThe calculation happens on your device, using your browser's own data.
  3. Take the resultRead the text, then copy, download, or share a link.

Reimplemented locally. Not derived from IT-Tools source.

Basis
independent
Licence
MIT
Last reviewed

Frequently asked questions

Why is kebab-case standard for URLs and filenames?

Hyphens naturally act as explicit word delimiters in web paths (SEO-friendly slugs). Unlike underscores or CamelCase, search engine indexers universally treat hyphens as space delimiters, improving keyword parsing.

How does the tokenizer handle uppercase sequences and acronyms?

The transformation safely splits acronym boundaries (e.g. 'XMLHttp' -> 'xml-http' or 'xmlhttp' depending on regex boundary rules), ensuring consistent lowercase hyphenated output.

Are international characters and accents preserved?

Kebab-case retains base Unicode characters but lowercases them. It does not perform ASCII transliteration. For strict ASCII slug generation, use the separate Slugify tool.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close