Build block__element--modifier the right way, normalized to kebab-case, with HTML and SCSS nesting examples, browser-only
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Enter a block name to start.
BEM reads block__element--modifier: double underscore before an element, double hyphen before a modifier. Every part is normalized to kebab-case.
What this tool does
Free BEM class name generator for front-end CSS. Type a Block, an optional Element and one or more Modifiers, and it assembles the class following the Block Element Modifier convention: a double underscore before the element and a double hyphen before each modifier, so card + title + active becomes card__title--active. Every part is normalized to kebab-case, which means cardTitle, Card Title and CARD_TITLE all settle on the same card-title segment and your stylesheet stays consistent. When you add several modifiers it prints one class per line, a base class plus one variant line each, exactly how you list them in a class attribute. It also outputs a ready HTML snippet and an SCSS nesting block using the ampersand parent selector so you can paste straight into a partial. Everything runs in the browser with one-click copy and a share link that reopens your exact block, element and modifiers.
Tool details
- Input
- Text
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How BEM Class Name Generator fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 CSS Formatter & Minifier Format and beautify CSS — sort properties, indent rules, expand or minify. Open
- 2 Case Converter Convert text between camelCase, snake_case, kebab-case, PascalCase, Title Case, UPPER, lower — instant, browser-only Open
- 3 URL Slug Generator Turn any title into a clean URL slug — lowercase, dashes, ASCII-safe transliteration, multiline batch — browser-only Open
Real-world use cases
Keep one team's CSS class names consistent
Three engineers touch the same component library and each has a favorite casing. One writes cardTitle, another card_title, a third CardTitle. Run every name through the generator and they all land on card__title, so a pull request diff never churns on style alone. The kebab-case normalization is the quiet enforcer here: nobody argues about casing in review because the tool already decided.
Convert a quick mockup into a BEM stylesheet
You sketched a card with a title, an image and a footer, plus a featured variant. List card as the block, add each element, and add featured as a modifier. Copy the class list into the markup and the SCSS nesting block into your partial. In a minute the throwaway mockup has a proper BEM structure instead of a pile of ad-hoc .title and .footer classes that will collide with the next component.
Teach BEM to a new front-end hire
Explaining double underscore versus double hyphen in the abstract rarely sticks. Hand the new hire the tool, have them type card, title and active, and the rule clicks the moment they see card__title--active appear with the matching SCSS. The share link lets you send a worked example in chat that reopens exactly as you built it, which beats a paragraph of prose about the convention.
Generate state modifiers for an interactive component
A menu item has several states: active, disabled, hovered, current. Put the block and element once, then list all four states as modifiers, one per line. You get menu__item plus four variant classes in one shot, ready to drop into your component's class logic and your stylesheet, instead of hand-typing each one and risking a single-hyphen typo that silently breaks the selector.
Common pitfalls
Nesting elements inside elements, like card__body__title. BEM elements are always flat under the block, so the right name is card__title even when the title sits visually inside a body wrapper. Keep one block, one double underscore, then the element name.
Using a single hyphen for a modifier, writing card-active instead of card--active. A single hyphen reads as part of the kebab-case name, so card-active looks like a block named card-active rather than a modifier on card. The tool always inserts the doubled separator so this never happens.
Making the modifier carry meaning on its own, like a global .active class. A BEM modifier should be scoped, card__title--active, not a bare .active that leaks across unrelated components and forces specificity hacks to override. Always attach the modifier to its block or element.
Privacy
The whole generator is plain JavaScript running inside your browser tab. The block, element and modifier names you type are never sent to a server and never logged. The only data that can leave your machine is the optional share link, which encodes the three fields in the URL query string so a teammate who opens it lands on the same class names. Class names are not sensitive, so this is safe, but if you would rather keep them off a URL, use the copy buttons and paste the text instead of sharing the link.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only