PX to REM Calculator
Convert between px and rem against a root font-size you control. One rem equals the root font-size set on the html element, which defaults to 16px in every major browser, so 24px becomes 1.5rem. Switch direction to turn rem values back into pixels, and copy the result straight into your stylesheet.
How to convert px to rem
- Use the toggle to pick a direction: 'px to rem' or 'rem to px'.
- Enter the number to convert in the 'Value to convert' box; its unit follows the direction you chose.
- Set 'Root font-size (px)' to whatever 1rem should equal, usually 16.
- Read the converted value in the highlighted result panel as it recalculates live.
- Press 'Copy result' to grab the number with its unit for pasting into CSS.
Examples
Convert a pixel size to rem
24 px at a 16 px root
1.5rem
Convert rem back to pixels
1.5 rem at a 16 px root
24px
Use a 10 px root for easy mental math
32 px at a 10 px root
3.2rem
Frequently asked questions
What is a rem in CSS?
A rem is a length unit equal to the root font-size of the page, which is set on the html element. If the root is 16px then 1rem is 16px and 1.5rem is 24px. Sizing in rem lets a whole layout scale from that single root value.
How is px to rem calculated?
Divide the pixel value by the root font-size. At the common 16px root, 24px is 24 divided by 16, which gives 1.5rem. To go the other way, multiply the rem value by the root, so 1.5rem times 16 is 24px.
Why is the default root font-size 16px?
Every major browser applies 16px as the default font-size to the html element unless a stylesheet or the user overrides it. That makes 16px the standard baseline, which is why the root field starts there.
Can I change the root font-size?
Yes. Set the root field to match your own CSS. Some teams set the root to 10px so 1rem equals 10px and conversions become tidy tenths, for example 32px becoming 3.2rem. The tool accepts any positive root value.
What is the difference between rem and em?
A rem is always relative to the root font-size, so it stays constant everywhere. An em is relative to the font-size of the current element, so it compounds when elements are nested. Rem avoids that surprise, which is why it is popular for global sizing.
Should I use rem or px for font sizes?
Rem is preferred for type and spacing because it respects the user's chosen base font-size and scales the interface from one value, which helps accessibility. Px still suits fixed details like a one pixel border where scaling is unwanted.
How precise are the results?
Values are shown rounded to six decimal places with trailing zeros trimmed, so 24px at a 16px root reads as a clean 1.5rem. That precision is far finer than any pixel a browser will actually paint.
What if I enter a zero or negative root?
The root font-size must be a positive number, since dividing by zero has no meaning and a negative root is not valid CSS. If you enter one, the tool asks for a positive root instead of showing a result.
Is anything sent to a server?
No. The conversion is plain arithmetic that runs entirely in your browser, so the values you type stay on your device and nothing is uploaded or logged.
Learn more
- PX vs REM in CSS: when to use each unit
A practical guide to pixels and rem in CSS, why rem scales with the root font-size, and how to choose the right unit for type and spacing.
Related tools
PX to EM Calculator
Convert px to em and em to px against a parent font-size. Em is relative to the parent element, not the root. Set the parent and copy the result.
Type Scale Calculator
Generate a modular type scale from a base size and a ratio. Get px and rem for every step, from small print to display headings. Free and exact.
CSS clamp() Calculator
Generate a responsive CSS clamp() for fluid font sizes and spacing. Set a min and max size with viewport breakpoints and copy the clamp() value instantly.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.