Convert kebab-case to camelCase!

String
Result

Convert kebab-case to camelCase!

Is the variable naming in the code you copied from somewhere else different from your code? Don't worry! It converts variables to your desired naming convention!

Converts hyphenated names to camelCase: font-size → fontSize, data-user-id → dataUserId. CSS properties, HTML attributes, CLI flags and many YAML keys are kebab-case, but the moment you touch them from JavaScript they become camelCase, as in element.style.fontSize, React's style prop or dataset.userId.

Paste a CSS rule, an attribute list or a set of flags to get the names you will use in script.

How to use

  1. Select kebab-case → camelCase.
  2. Paste CSS declarations, attribute names or option names into the String box.
  3. Copy the result and adjust the surrounding syntax for JavaScript (quotes, commas).

Example

Input (kebab-case)
.toast {
  font-size: 14px;
  line-height: 1.4;
  z-index: 50;
}
Output (camelCase)
.toast {
  fontSize: 14px;
  lineHeight: 1.4;
  zIndex: 50;
}

The three CSS property names are converted, ready for a React style object; the selector .toast and values like 14px stay. You still need to quote string values and replace ; with , for a JS object.

Supported features

  • Removes each hyphen and capitalizes the next letter: line-height → lineHeight.
  • Leading dashes are kept: --main-color → --mainColor, which matters if you paste CSS custom properties.
  • Numbers and dates with hyphens, such as 2024-01-01, are left unchanged.

Use cases

From CSS to a React style object

When a design hands over plain CSS for a single element, converting the declarations gives the camelCase keys React expects in style={{ ... }}.

Reading data attributes in JavaScript

data-order-id on an element is read as el.dataset.orderId. Converting gives dataOrderId; drop the data prefix and lowercase the next letter to get the dataset key.

Parsed CLI options

Libraries such as yargs and commander expose --max-retries as maxRetries on the parsed options, so this shows the property name your code will read.

Notes and limitations

  • Custom property names keep their -- prefix, and the result is no longer a valid CSS variable reference. Do not convert those if you need them as CSS variables.
  • A hyphen inside an expression without spaces, like total-discount, is indistinguishable from a kebab name and will be converted to totalDiscount. Paste names, not arithmetic.

FAQ

Does -webkit-transform become WebkitTransform?

No. The leading hyphen stays and you get -webkitTransform. React expects WebkitTransform for vendor prefixes, so fix those few names by hand.

What happens to item-2?

The digit segment is joined like any other word, so item-2 becomes item2 and col-12-md becomes col12Md. v2-api also works: v2Api.