Convert camelCase to kebab-case!

String
Result

Convert camelCase to kebab-case!

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 camelCase names to kebab-case: backgroundColor → background-color, dryRun → dry-run. Lowercase words joined by hyphens are what CSS properties, HTML attributes, URL slugs and most command-line flags use.

It is most useful when moving between JavaScript and markup or the shell: a React inline style object back to a stylesheet, Vue/Angular props written in script to their template attribute form, or option names from a JS config to --long-flags.

How to use

  1. Keep camelCase on the left and kebab-case on the right.
  2. Paste style declarations, prop names or option names into the String box.
  3. Copy the converted text from Result. If you change either dropdown, the address changes too, so the pair you use most can be bookmarked.

Example

Input (camelCase)
backgroundColor: #fff;
borderRadius: 8px;
boxShadow: 0 1px 2px #0002;
--dryRun --outputDir dist
Output (kebab-case)
background-color: #fff;
border-radius: 8px;
box-shadow: 0 1px 2px #0002;
--dry-run --output-dir dist

Property names from a React style object become real CSS property names, and the camelCase part of --dryRun is converted while the leading -- is kept. Values such as #fff and 8px are untouched.

Supported features

  • Every capital letter becomes a hyphen plus the lowercase letter: boxShadow → box-shadow.
  • Prefixes such as -- or . in front of a name are preserved because only the camelCase word itself is replaced.
  • Digits stay with their word: grid2Columns → grid2-columns.

Use cases

From inline styles back to CSS

When a component's style={{ ... }} grows too big and you move it into a .css or .module.css file, converting the property names saves rewriting marginTop, zIndex, textAlign by hand. You still need to add semicolons and drop the quotes around values.

Props in Vue DOM templates

Vue lets you declare itemCount in script but expects item-count when the template is written in plain HTML. Paste the prop list to get the attribute names.

CLI flags from option objects

A tool configured with { outputDir, dryRun } usually exposes --output-dir and --dry-run on the command line.

Notes and limitations

  • A run of capitals is read as one acronym, so innerHTML becomes inner-html and getHTTPResponse becomes get-http-response. Two acronyms written back to back (parseXMLHTTPRequest) cannot be told apart and come out as parse-xmlhttp-request.
  • Vendor-prefixed JS names like WebkitTransform start with a capital, so they are not camelCase and stay unchanged; convert them separately.

FAQ

Does it convert CSS-in-JS values or add units?

No. Only the identifiers change. A value like fontSize: 14 stays 14; add px yourself when moving to CSS.

Can I use the result directly as a URL slug?

For identifiers, yes: orderHistory becomes order-history. For free text with spaces or non-ASCII characters, use the string case converter instead, since this page only rewrites camelCase words.