ποΈ PX to REM Converter β CSS Pixel and Root Font Size
Enter a pixel size and the root font size used by the page. The converter shows the rem value and can turn rem back into pixels for the same root.
What this tool does
The PX to REM converter translates pixel values into rem units and back, using the root font size you specify. Since one rem equals the root font size, the conversion is a division or multiplication, but the correct root value is easy to forget.
It is useful when a design file uses pixels while a stylesheet uses rem, or when a project changes its base font size and existing spacing and typography values need to be rewritten consistently.
When to use it
- Converting a design specification in pixels into rem values.
- Checking a rem value against the standard 16-pixel browser default.
- Recalculating spacing after changing the root font size.
- Producing consistent type and spacing scales for a stylesheet.
How it works
- Set the root font size. 16px is the usual browser default.
- Enter a pixel value and press Convert px to rem, or enter rem and press Convert rem to px.
- Copy the CSS value. 1rem always equals the root font size you entered.
Worked example
With a root size of 16 pixels, 24px converts to 1.5rem, and 1.25rem converts back to 20px. If the root is changed to 18 pixels, the same 1.25rem now equals 22.5px, which shows why the root value must match the page base size before the values are pasted into CSS.
- 16px at a 16px root is 1rem.
- 24px at a 16px root is 1.5rem.
- 1.25rem at an 18px root is 22.5px.
Accuracy and limitations
- The conversion assumes the root font size you enter. It does not read the page computed styles or account for browser zoom and user font-size settings.
- Results can contain long decimals; round them to a sensible precision for CSS.
- Only px and rem are supported. em, percentages, vw and other relative units are not converted.
Privacy and data handling
Conversions run locally in JavaScript. The values you enter are not uploaded, stored or shared with any third party.
Frequently asked questions
What is a rem?
A rem is a CSS length equal to the font size of the root element, usually the html element. It does not depend on the parent element's font size the way em does.
Why would I change the root size?
Some designs set html { font-size: 62.5% } so 1rem is 10px, or they use a larger root for accessibility. Match the root used by the stylesheet.
Does this change my website?
No. It only calculates the equivalent length so you can paste it into CSS.
Should I always use 16px as the root?
16px is the usual browser default, but check your project. If the html element sets a different font-size, use that value for accurate conversions.
Related tools
More Design tools βColor Contrast Checker
Measure WCAG contrast between two hex colors for text and interface graphics.
HSL to Hex Converter
Convert between HSL and hexadecimal color formats privately.
Aspect Ratio Calculator
Solve width, height and simplified aspect ratios without breaking proportions.
CSS Gradient Generator
Generate CSS linear and radial gradients with live preview and copy-ready code.