Case Converter→Specialized Version
🔤

BEM Class Name Converter

Convert text to kebab-case

Acronyms split the way programmers expect: XMLHttpRequest becomes xml_http_request, not x_m_l_http_request.

BEM Class Name Converter

kebab-case writes hello-world-example. BEM writes block__element--modifier, with each of the three parts in kebab-case: card__title--featured. The point is a flat, specificity-free namespace — every selector is one class, so nothing wins by nesting and the cascade never surprises you. That predictability is why BEM survived the arrival of CSS modules and utility frameworks.

Conversions

Inputkebab-case
hello world examplehello-world-example
XMLHttpRequestxml-http-request
user_first_nameuser-first-name
Total Order Counttotal-order-count
Lower-casing makes acronyms disappear into the string: XMLHttpRequest becomes xml-http-request. That is the correct behaviour for a URL or a CSS class, where case sensitivity varies by context and mixed case causes more problems than it solves.

The Same Text in Other Cases

CaseResult
camelCasehelloWorldExample
PascalCaseHelloWorldExample
snake_casehello_world_example
SCREAMING_SNAKE_CASEHELLO_WORLD_EXAMPLE
Train-CaseHello-World-Example
dot.casehello.world.example

Why BEM Uses Three Parts

block__element--modifier encodes the relationship in the name, so the stylesheet never needs a descendant selector. Every rule is a single class, specificity stays flat, and nothing wins by being nested more deeply — which is what makes a large BEM stylesheet predictable to change.

The double underscore and double hyphen exist to be visually distinct from the single hyphens inside each part, so card__nav-item--is-active parses unambiguously by eye.

Converting in Code

``javascript const kebab = (s) => words(s).map((w) => w.toLowerCase()).join('-'); `

A hyphen is a subtraction operator in most languages, so kebab-case identifiers cannot be used unquoted in code. That is precisely why it belongs in URLs, CSS and filenames and not in variable names.

Converting at the API Boundary

The recurring friction is that JavaScript uses camelCase and Python, Ruby, Go and SQL use snake_case. The fix is to convert in exactly one place — the client that talks to the API — rather than letting both conventions into the same codebase.

`javascript const toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase()); const toSnake = (s) => s.replace(/[A-Z]/g, (c) => '_' + c.toLowerCase());

// Recursively, for a whole payload const convertKeys = (value, fn) => Array.isArray(value) ? value.map((v) => convertKeys(v, fn)) : value && typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([k, v]) => [fn(k), convertKeys(v, fn)])) : value; `

Two things to watch: keys that are user data rather than field names must not be converted, and the round trip is not always lossless — userID → user_id → userId changes the original.

Where Each Convention Is Mandatory

Not stylistic — these will break if you deviate:

ContextRequirement
Environment variablesUppercase with underscores; POSIX reserves lowercase
Custom HTML elementsMust contain a hyphen
Python modulesCannot contain hyphens; the import statement will not parse
SQL identifiersFolded to one case unless quoted, so camelCase does not survive
React componentsMust start uppercase, or JSX treats it as an HTML tag

Renaming Safely

A find-and-replace across a codebase will hit strings, comments and unrelated identifiers. Use your language server's rename symbol instead — it understands scope. For a bulk rename across files, restrict the pattern with word boundaries and review the diff before committing:

`bash grep -rn '\buserId\b' src/ # look first ``

Frequently Asked Questions

When should I use kebab-case?

BEM writes `block__element--modifier`, with each of the three parts in kebab-case: `card__title--featured`. The point is a flat, specificity-free namespace — every selector is one class, so nothing wins by nesting and the cascade never surprises you. That predictability is why BEM survived the arrival of CSS modules and utility frameworks.

How are acronyms handled?

Correctly. `XMLHttpRequest` becomes `xml-http-request`, treating the run of capitals as one word rather than splitting every letter.

Does the converter handle numbers and punctuation?

Numbers stay attached to the word they belong to; punctuation and separators are treated as word boundaries and removed. `order-2-total` and `order_2_total` both produce the same words.

Related Tools

Explore other tools you might find useful:

More Case Converter tools

You might also need