HomeProgrammingKebab Case Converter

Online Kebab Case Converter Tool

Automatically detect various naming formats and convert to Kebab-case with one click, helping code standardization.

What Is Kebab Case?

Kebab case (also known as hyphen case) is a naming convention where each word is separated by a hyphen (-) and all letters are lowercase. The name comes from the visual resemblance of the hyphens to skewers holding words together like pieces of meat on a kebab. It is widely used in front‑end development (CSS classes, HTML attributes), URL paths, npm package names, configuration keys, and many other web‑facing contexts. Compared to macro style (all caps with underscores), kebab case prioritizes readability and typing speed, while macro style emphasizes prominence and constant‑value identification.

Core Rules of Kebab Case

All Lowercase

Every letter must be lowercase – this is the most distinctive feature of kebab case. In contrast to macro style (all uppercase), lowercase text feels softer on the eyes and blends naturally into prose, reducing visual fatigue during long coding sessions.

Hyphen Separation

Words are joined by a single hyphen -, for example user-profile. The hyphen is directly available on the keyboard without needing the Shift key, making it faster to type than underscores.

No Leading, Trailing, or Consecutive Hyphens

Identifiers must not start or end with a hyphen, nor contain consecutive hyphens (e.g. user--profile), as these can be misinterpreted by some parsers or cause unexpected behavior.

Numbers and Abbreviations

Numbers are allowed (e.g. version-2), though they are generally not placed at the beginning. For acronyms like API or URL, kebab case treats them as normal words (e.g. api-key), whereas macro style would render them fully uppercase (e.g. API_KEY). This is one of the key differences between the two conventions.

Common Use Cases for Kebab Case

Kebab case dominates the front‑end and web ecosystem, and also plays a significant role in configuration management.

HTML / CSS Class Names and IDs

In HTML and CSS, class names and IDs are frequently written in kebab case – for example, nav-bar and btn-primary. CSS property names themselves also use hyphens (like font-size and background-color), ensuring consistency across the stylesheet. Macro style, by contrast, is rarely seen in this domain.

URL Paths and File Names

For SEO‑friendly and human‑readable URLs, path segments often use hyphens to separate words, such as /user-profile or /api-version. Many static site generators and CMS platforms recommend this practice, while macro style is almost never used for URLs.

Configuration Keys

In JSON, YAML, and .env files, keys often adopt kebab case (e.g. max-retry-count), but environment variables typically use macro style (e.g. MAX_RETRY_COUNT). Both have their place: kebab case is more readable, macro style is more visually prominent and signals that the value is a constant.

npm Package Names

npm (Node Package Manager) enforces that package names use kebab case and are all lowercase – for example, lodash and express-validator. This makes kebab case the standard within the JavaScript ecosystem.

Pros and Cons of Kebab Case

Advantages

  • Excellent readability – hyphens clearly separate words, making long names easy to scan.
  • Fast to type – the hyphen requires no Shift key, speeding up input.
  • URL‑friendly – search engines recommend hyphens as word separators, benefiting SEO.
  • CSS native – CSS properties and class names support hyphens natively, no escaping needed.
  • Case‑insensitive – all lowercase avoids case‑sensitivity issues, which is handy across platforms.

Disadvantages

  • Slightly longer visually – hyphens add extra characters compared to camel case.
  • Clashes with programming language variables – many languages (e.g. Java, Python) do not allow hyphens in variable names, so kebab case cannot be used for identifiers.
  • No type information – unlike macro style, it cannot convey whether something is a constant or a variable through letter case.
  • May need escaping in command lines – in shells, hyphens are often interpreted as option flags, sometimes requiring escaping.

Kebab Case vs. Macro Style – A Deep Dive

Although both kebab case and macro style use separators, their domains are completely different. Macro style (all caps + underscores) is primarily used for constants and macros in programming languages, emphasising immutability and visibility. Kebab case, on the other hand, focuses on the web front‑end, URLs, and configuration keys, prioritising readability and user friendliness.

Case difference: macro style is fully uppercase, which draws attention in code and clearly marks constants; kebab case is fully lowercase, visually softer and better suited for user interfaces and textual content.

Separator choice: macro style uses underscores, which are common in variable names, while hyphens in HTML/CSS have a special semantic meaning (e.g. attribute names) – each convention fits its own ecosystem.

Cross‑language compatibility: macro style is supported in virtually every programming language (for constants), whereas kebab case is largely confined to the web and configuration realms, and most programming languages do not allow hyphens in identifiers.

Best Practices for Using Kebab Case

  • Stay consistent – adopt kebab case project‑wide and avoid mixing with snake or camel case.
  • Be descriptive – choose meaningful noun or adjective combinations, e.g. user-avatar is better than ua.
  • Avoid abbreviations – unless they are widely recognised (like id or url), prefer full words.
  • Watch CSS specificity – while using kebab case for class names is standard, avoid excessive nesting.
  • Leverage tooling – many front‑end tools (Webpack, ESLint) can enforce and validate kebab case automatically.

How to Choose: Kebab Case or Macro Style?

The choice depends entirely on the context:

  • If you are writing HTML/CSS, defining URL paths, or creating user‑friendly config keys – kebab case is your best bet.
  • If you are defining constants, macros, or environment variables in code – macro style is the industry standard.
  • If your project spans multiple domains – you can adopt different styles for different layers, but document the decision clearly.

Our kebab case page is designed to help you understand this convention, while our macro style converter focuses on constant naming. Together, they support overall code quality and consistency.

Conclusion

Kebab case is an indispensable naming convention in the web development world. Its simplicity, readability, and URL‑friendliness have made it the de facto standard for CSS, HTML, and configuration files. At the same time, understanding its differences from macro style equips developers to make the right choice in each context. Whether you are building front‑end components or designing API routes, mastering kebab case will make your code more professional and easier to maintain.