Convert CSS rules to React JSX style objects
In React, inline styles are defined as JavaScript objects with camelCase properties, rather than CSS strings. For example, `background-color` becomes `backgroundColor`. Converting CSS to JSX style objects allows you to use CSS-like syntax and convert it to the format React expects for inline styles.
This tool transforms CSS rules into JSX style objects. It handles property name conversion (kebab-case to camelCase), value conversion (e.g., pixel values become numbers when possible), and creates JavaScript objects ready to use in React components.
All processing is done locally in your browser – your code never leaves your device.
Step 1: Paste your CSS into the input area.
Step 2: Click "Convert to JSX". The tool transforms CSS properties to camelCase.
Step 3: The JSX style object appears in the output area.
Step 4: Copy the JSX using the "Copy JSX" button.
The converter handles multiple CSS rules, each becomes a separate style object with the class name as the variable name.
Input CSS:
.box { background-color: #f00; font-size: 16px; margin-top: 10px; }
Output JSX:
const boxStyles = {
backgroundColor: "#f00",
fontSize: "16px",
marginTop: "10px"
};