Loading JSX to CSS Converter...

How to Convert JSX to CSS - Step by Step Guide

Step 1

Input Your JSX Style Objects

Start with the styles you want to move out of your components. The converter reads three shapes: const style objects, objects of objects (const styles = { card: {…} }) and style={{ … }} written straight in JSX. Bring them in whichever way is easiest:

•
Paste directly: Copy a whole component, a few style objects, or just the object from inside style={{ }} and paste it into the input editor
•
Upload a file: Click "Upload" to pick a .js, .jsx, .ts, .tsx or .txt file
•
Try the sample: Click "Sample" to load example style objects and see how the converter works

Example: JSX Style Object Input

Here's what React inline style objects look like:

const cardStyle = {
  backgroundColor: '#ffffff',
  borderRadius: '8px',
  boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
  padding: '20px',
  marginBottom: '16px',
  maxWidth: '400px'
};
Step 2

How the Conversion Works

Half a second after you stop typing, the converter reads the code (it never runs it) and:

•
Converts property names: Transforms camelCase to kebab-case (backgroundColor → background-color)
•
Adds px the way React does: 20 becomes 20px, but unitless properties like lineHeight, zIndex, opacity and fontWeight keep a bare number, and strings such as '14.50px' are copied as typed
•
Creates CSS selectors: Generates class names from variable names (cardStyle → .card)

Example: Clean CSS Output

The same styles, now as standard CSS:

.card {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 16px;
  max-width: 400px;
}
Step 3

Review the CSS Output

The output panel shows one CSS rule per style object. Before you copy it, look at:

•
The notes: values that are only known when the code runs (theme.primary, a function call, a nested :hover object) are listed above the output instead of being dropped without a word
•
Class names: each rule is named after its variable, its key or its element, with -2 added if two would clash
•
Ready to use: Swap style={cardStyle} for className="card" once the CSS is in your stylesheet
Step 4

Export Your CSS

When the CSS looks right, take it with you:

•
Copy to clipboard: One-click copying for quick pasting into your CSS file
•
Download as file: Save as a .css file for adding to your project
•
Keeps up with edits: change the code and the CSS follows a moment later

Frequently Asked Questions

What does JSX to CSS conversion do?

It takes the plain JavaScript objects React uses for inline styles and writes them out as ordinary CSS rules. const cardStyle = { padding: 20, backgroundColor: '#fff' } becomes .card { padding: 20px; background-color: #fff; }, ready to move into a stylesheet or a CSS module.

Why move inline styles into CSS?

Inline styles can't do :hover, :focus, media queries, keyframes or ::before, and they are repeated on every element that uses them. A class in a stylesheet can do all of that, is cached by the browser and is easy to override. Converting is usually the first step when a component outgrows its style prop.

How are property names converted?

The same way React does it when it writes the style attribute: every capital letter becomes a dash plus the lowercase letter, so backgroundColor becomes background-color. Vendor prefixes follow from that rule: WebkitTransition becomes -webkit-transition, MozUserSelect becomes -moz-user-select, and msTransform (lowercase m, as React expects) becomes -ms-transform. Custom properties such as '--brand-color' are written exactly as they are.

When does a number get px?

React adds px to a plain number unless the property is unitless, so padding: 20 becomes 20px while lineHeight: 1.5, zIndex: 10, opacity: 0.5, flex: 1 and fontWeight: 700 stay bare. Zero never gets a unit, and neither does a number on a custom property. Strings are copied as typed, so '14.50px' or '00501' come out unchanged. A number literal keeps the digits you wrote, even a very long one that JavaScript itself would round.

How are the CSS class names chosen?

A variable gives its name without a trailing Style, in kebab-case: cardTitleStyle becomes .card-title. An object of objects, like const styles = { card: {…}, title: {…} }, gives one class per key. A style={{ … }} written straight in JSX uses the element's first static className, or the tag name (.div-style) when there isn't one. If two rules would get the same name, the second gets -2.

What happens to values the converter can't read?

Nothing is run, so a value that is only known at runtime, such as theme.primary, a function call, a spread of an object that isn't in the pasted code, or a nested :hover object, is left out and named in a note above the output. Booleans, null and undefined are skipped because React doesn't write them either. A string with a stray ; or } is escaped so it can't break the rest of the CSS.

Is my code sent anywhere?

No. The conversion runs in your browser, and nothing you paste or upload is sent to a server. Nothing is kept: a reload starts with an empty editor.

Going the other way? CSS to JSX turns stylesheet rules into React style objects, and the CSS Formatter tidies the result once it is in your stylesheet.