PX to REM Converter
The PX to REM Converter changes pixel values to rem and rem back to pixels at any root font size, 16px by default. Paste a stylesheet to change every px value at once, with options for 1px borders and media queries. It is for web developers, designers and students writing CSS.
16 is the browser default. Change it only if your CSS sets a different size on html.
Convert a whole stylesheet
Common sizes
| Pixels | Rem | Pixels | Rem |
|---|
Converted on this device. Rem is relative to the root (html) font size; em is relative to the parent element, so use em only where that is what you want.
What is the PX to REM Converter?
The PX to REM Converter does the one sum behind rem units: rem equals pixels divided by the root font size. A rem is relative to the font size of the html element, which is 16px in every major browser unless the visitor or your CSS changes it, so 24px is 1.5rem and 14px is 0.875rem. Using rem for font sizes and spacing lets text grow when someone sets a larger default font in their browser, which helps people with low vision. Type single values or a list, convert rem back to pixels, or paste CSS to change every px value at once. You can keep 1px hairlines in px, and choose whether sizes in media queries stay in px or become em. Comments are left as they are.
Who it is for: Front-end developers moving a design to rem units, designers handing over sizes from Figma, and students learning CSS.
How to use the PX to REM Converter
- Check the root font size: 16px unless your CSS sets another size on html.
- Type a pixel value or a list to get rem, or a rem value to get pixels.
- To convert a stylesheet, paste it in the CSS box and choose how to treat 1px values and media queries.
- Copy the values or the converted CSS.
Why use it
- Whole stylesheetsPaste CSS and every px value becomes rem in one go.
- Any root sizeWorks with 16px, the 62.5% (10px) trick or any size you set.
- Both waysConvert rem back to pixels to check a design.
- Sensible defaultsKeeps 1px borders and leaves media queries alone unless you choose.
At a glance
- What you put in
- Pixel or rem values (single or a list), a root font size, or a CSS stylesheet
- What you get
- Rem values, pixel values, the stylesheet with px changed to rem, and a table of common sizes
- Limits
- Converts only px written in the CSS you paste, not values set by JavaScript; px inside comments, url() and quoted text is left alone; other units such as pt are not changed
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
.card { padding: 24px; font-size: 14px; border: 1px solid #ddd; } and @media (min-width: 768px) { .card { padding: 32px; } } at a 16px root.card { padding: 1.5rem; font-size: 0.875rem; border: 1px solid #ddd; } and @media (min-width: 768px) { .card { padding: 2rem; } }. 3 values changed to rem, 1 1px value kept.24 ÷ 16 = 1.5, 14 ÷ 16 = 0.875 and 32 ÷ 16 = 2. The 1px border stays in px, and the 768px in the media query stays as it is.
When to use something else
- If you change the root font size in your CSS with a percentage (html { font-size: 62.5% }), set the root font size here to the pixel result, 10px for 62.5%.
- To change colours between HEX, RGB and HSL, use the Colour Converter. To tidy the converted CSS, use the Code Beautifier.
- Em values depend on each element's parent, so this tool does not convert to em, except for media queries where em always means the browser default size.
Questions people ask
How do I convert px to rem?
Divide the pixel value by the root font size. With the default of 16px, 24px ÷ 16 = 1.5rem, 12px = 0.75rem and 32px = 2rem. To go back, multiply: 1.25rem × 16 = 20px.
What is 1rem in pixels?
1rem equals the font size of the root html element. In Chrome, Edge, Firefox and Safari that is 16px by default, so 1rem = 16px, unless your CSS sets another size on html or the visitor has chosen a larger default font.
What is the difference between rem and em?
Rem is relative to the root html font size, so 1rem is the same everywhere on the page. Em is relative to the font size of the element's parent, so it changes as elements are nested. Rem is easier to predict for spacing and font sizes.
Why use rem instead of px?
Rem sizes grow when a visitor sets a larger default font size in their browser, so your text stays readable for people who need bigger text. Pixel font sizes ignore that setting. Many design systems use rem for type and spacing and keep px for hairline borders.
Should media queries use rem or em?
In a media query, rem and em both use the browser's default font size, not the size you set on html. Many developers use em or keep px there. This tool leaves media query sizes in px by default, or changes them to em based on 16px if you choose.
What is the 62.5% trick?
Setting html { font-size: 62.5% } makes the root 10px in a browser with a 16px default, so 1.6rem = 16px and maths is easier. If you use it, set the root font size here to 10. Remember to set body text back to a readable size such as 1.6rem.