Toolvist

BEM Class Name Generator

Generate consistent BEM class names — block, element and modifier — from a component name. Free BEM naming tool for cleaner, predictable CSS.

The standalone component name, e.g. card, nav, form.

Comma separated. Become block__element.

Comma separated. Become block--modifier.

Generated classes

Enter a block name to begin…

Free BEM Class Name Generator

The BEM Class Name Generator builds consistent Block__Element--Modifier class names so your CSS stays predictable and collision-free. Enter a block, add elements and modifiers, and copy the finished class list.

Class naming sits alongside the CSS to Tailwind Converter and the CSS Formatter & Beautifier. For the layout properties the classes will carry, the CSS Flexbox Generator and CSS Grid Generator are the companions.

How to use the BEM Generator

  1. 1 Enter the block name, then an element name if needed.
  2. 2 Add modifiers, choosing between a single value and a key-value pair.
  3. 3 Read the generated class name in the convention you selected.
  4. 4 Copy it, or build the full set of classes for a component at once.

What BEM solves

The problem BEM addresses is specificity and collision. In a large stylesheet, names collide across components, and the usual response is to nest selectors deeper until specificity becomes unpredictable and styles cannot be overridden without escalation.

BEM's flat, self-describing class names keep specificity uniform — almost every rule is a single class — which makes the cascade predictable. The cost is verbose names, and the benefit is that a change to one component's styles cannot accidentally affect another.

  • Block, element, modifier: `block__element--modifier`.
  • Every selector is a single class, so specificity stays flat.
  • Names are self-describing without inspecting the markup.
  • Long names are the price; deep nesting is the alternative cost.

What is BEM?

BEM stands for Block, Element, Modifier. A block is a standalone component (card), an element is a part of it (card__title), and a modifier changes a state or variant (card--featured). The pattern keeps specificity flat and names self-documenting.

Frequently asked questions

What does BEM actually stand for?

Block, element, modifier. A block is a standalone component. An element is a part of a block that has no meaning outside it. A modifier changes the appearance or state of a block or element. The naming convention encodes those relationships, which is its entire purpose.

What is the difference between a single-value and a key-value modifier?

A single-value modifier expresses a state that is either present or not, such as disabled. A key-value modifier has a range, such as a size of small or large. The distinction matters because a key-value modifier is extensible without inventing new names for each value.

Should element names repeat the block name?

No. Within a block, element names are deliberately unprefixed beyond the block, so a button inside a card is `card__button` rather than `button__button`. The block already scopes it. Repeating the block name inside deeply nested elements is the most common way to make BEM names grow unmanageably long.

Related Developer Tools

Browse all Developer Tools →

You might also need

Tools from other categories that people pair with the BEM Generator:

Browse the full tool directory →