PX to REM converter
Convert pixels to rem and rem to pixels at any root font size, or convert a whole stylesheet at once. Free, no sign-up, and everything runs in your browser.
The font size of the html element. Browsers use 16px unless the page or the user changes it.
24px = 1.5rem at a 16px root font size.
Convert a whole stylesheet
Paste CSS, SCSS or a list of values. Every value with the unit is converted; names like icon-16px.png stay as they are.
.card {
padding: 1.5rem 2rem;
margin-bottom: 2.5rem;
border: 1px solid #e5e7eb;
border-radius: 0.75rem;
}
.card h2 {
font-size: 1.75rem;
line-height: 2.25rem;
margin: 0 0 0.5rem;
}
@media (min-width: 48rem) {
.card { padding: 3rem; }
}px to rem table at 16px
What this px to rem converter does
This tool converts pixels to rem and rem back to pixels at any root font size. Type in either field and the other one updates at once. Below it, you can paste a whole stylesheet and convert every px value to rem (or every rem value to px) in one step, and a table shows the common sizes at your root font size.
One rem is the font size of the root element, which is normally the <html> element.1 Browsers start at a font size of 16px, so 1rem is 16px unless the page or the person reading it changes that. The math is simple:
- px to rem: rem = px ÷ root font size. At 16px, 24px is 24 ÷ 16 = 1.5rem.
- rem to px: px = rem × root font size. At 16px, 0.875rem is 14px.
Everything runs in your browser. Nothing you type or paste is sent anywhere.
How to use it
- Leave Root font size at 16 unless your CSS sets a different size on
html. If your stylesheet hashtml { font-size: 62.5%; }, the root is 10px, so enter 10. - Type a value in Pixels or REM. You can paste values with the unit, like
24pxor1.5rem. Use the copy icon in the field to copy the value with its unit. - To convert a file, paste it under Convert a whole stylesheet, choose px to rem or rem to px, and select Copy CSS. Values inside names, such as
icon-16px.pngor a.w-2remclass, are left alone. Run the result through the CSS formatter if you also want it tidy or minified.
Values in @media conditions are always converted at 16px, because media queries ignore the font size your CSS sets on html (see the FAQ below). By default, values of 1px and less stay in px. Hairline borders and outlines usually should not grow when someone picks a larger font, and 1px at a 16px root would become 0.0625rem, which is hard to read in code.
Why use rem instead of px?
People can set a larger default font size in their browser. Sizes in rem follow that setting, and sizes in px do not. MDN says it is best to use values relative to the user's default font size, and that px font sizes are not accessible because some browsers then can't change them.2 WCAG success criterion 1.4.4 (level AA) asks that text can be resized up to 200 percent without assistive technology and without losing content or functionality.3 Font sizes, spacing around text and breakpoints in rem make that much easier to pass.
Pixels are still the right unit for some things: borders, shadows, and images that must stay sharp at an exact size. A CSS pixel is not a screen pixel; it is defined as 1/96 of an inch, so it already scales with screen density.1
A clean landing page that still reads well at 200% zoom is a small thing that makes a product feel finished on launch day.
More free tools
HTML to Markdown converter
HTML to Markdown converter that runs in your browser. Paste HTML or rich text from a web page, Google Docs or Word and get clean GitHub Markdown.
ASCII table and converter
ASCII table with all 128 codes in decimal, hex, octal and binary, plus a converter from text to ASCII codes and back. Runs in your browser.
Keycode finder
Keycode finder that runs in your browser. Press any key to see its JavaScript keyCode, key, code and location, and copy a ready keydown handler.
Image converter
Image converter that runs in your browser. Convert PNG, JPG, WebP, AVIF, GIF and SVG files in bulk, with quality and resize options. No uploads.
Test credit card numbers generator
Test credit card numbers for form and checkout tests, made in your browser. Generate valid-format numbers for 7 card networks and check any number.
Random string generator
Random string generator that runs in your browser. Make secure random strings, API keys and tokens with your own length, characters and prefix.
Frequently asked questions
Sources
MDN Web Docs: <length> CSS type (rem, em and px)
MDN Web Docs: font-size (accessibility of relative sizes)
W3C: Media Queries Level 4 (units in media queries)
W3C: CSS Values and Units Module Level 4 (font-relative lengths)