Convert px to rem or em and back, or turn every px in a stylesheet into rem
Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 22 Oct 2026.Divide the pixel value by the root font size: with the browser default of 16px, 24px is 24 / 16 = 1.5rem and 14px is 0.875rem. To go back, multiply: 1.5rem × 16 = 24px. Paste a stylesheet to convert every px in it, keeping selectors, urls and 1px borders as they are.
Set the root font size; 16px is the browser default, 10px if your site uses the 62.5% trick.
Type a value such as 24px to get 1.5rem, or 1.5rem to get 24px, or read the table of common sizes.
To convert a whole stylesheet, paste it into the CSS box; selectors, urls and comments stay as they are.
Choose whether to keep 1px borders and media queries in px, then click Copy.
Sizes in rem follow the reader's own font-size setting, so text and spacing grow together for anyone who has set a larger default. Designs are still handed over in pixels, and this converter does the arithmetic both ways.
One value. Type 24px and read 1.5rem; type 1.5rem and read 24px. A bare number counts as px. Change the root font size if your site sets one: many sites set html to 62.5%, which makes 1rem equal 10px. The table lists the common sizes for the root size you choose, in rem or in em.
A whole stylesheet. Paste CSS and every px length in a declaration is converted as you type. What stays as it is:
| Left alone | Why |
|---|---|
Selectors such as .mt-16px |
changing a class name would break the HTML |
Property names such as --gap-12px |
only values are lengths |
Strings, comments and url(...) |
file names and text are not lengths |
1px and below, by default |
hairline borders should stay one device pixel; set the limit to 0 to convert them |
Uppercase PX |
the usual way to mark a value that must stay in pixels |
Media queries are different. In a media query, rem and em do not use the font size your page sets: Media Queries Level 4 says relative units there are based on the initial font size, which is the browser default of 16px. A breakpoint of 768px is therefore 48em even on a 62.5% site, where 76.8rem would be wrong. Media queries are left in px by default, or converted with 16 if you choose.
em works the same way as rem but relative to the parent element's font size, so set the size to the parent's when you pick em. Values are rounded to the decimals you choose, four by default, and 0px becomes 0. Nothing you paste leaves your browser. Related tools: CSS Clamp Generator, CSS Formatter, Box Shadow Generator.
Divide the pixel value by the root font size. Browsers default to 16px, so 24px is 1.5rem, 14px is 0.875rem and 32px is 2rem. Type the value above, or paste a whole stylesheet to convert every px in it at once with the same root size.
One rem equals the font size of the html element. When the page does not set one, that is the browser default of 16px, unless the reader has changed it in their settings. A site that sets html to 62.5% makes 1rem equal 10px for readers with the default.
A rem is relative to the root html font size, so it means the same everywhere on the page. An em is relative to the font size of the element itself, or its parent for the font-size property, so nested ems multiply. Use rem for predictable spacing.
In a media query, rem and em always refer to the browser's initial font size, usually 16px, not to the size your page sets on html. So 768px becomes 48em even on a 62.5% site. Em breakpoints follow the reader's zoom and default size, which px breakpoints do not.
A border of 0.0625rem can round to zero or blur on some screens, while 1px is always drawn as one device pixel or more. Values of 1px and below stay in px by default; set the limit to 0 if you want every value converted.
No. The conversion runs in your browser as you type, and nothing you paste is sent or stored. Selectors, property names, strings, comments and url() values are copied exactly, so only lengths change and the rest of the file stays byte for byte the same.
Rates and rules change; check the source before you rely on a figure.
Still stuck? Ask about PX to REM Converter and anybody who knows can answer. No account needed.
On the related tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · Query String Parser – Split a URL query string into a table of decoded parameters.