

In modern web development, using relative units like REM and EM instead of pixels creates responsive, scalable designs. Whether you’re designing in Figma, writing CSS, or coding in JavaScript, converting pixels to REM is essential. This article covers everything from using a dev unit converter to Sass functions, and even converting REM to percentage or width/height units.
Pixels (px) are fixed units, while REM (root em) is scalable and based on the root font size (typically 16px). Using REM makes your design responsive, accessible, and consistent across different devices.
A dev unit converter helps quickly convert pixels to REM without manual calculations. If the base font size is 16px, then:
16px = 1rem
32px = 2rem
You can use online tools, browser extensions, or build your own converter in JavaScript.
Designers using Figma often wonder how to convert pixel to rem Figma style. While Figma uses pixels by default, you can simulate REM by dividing your pixel value by 16. For example:
24px β 1.5rem
48px β 3rem
Pro tip: Add notes in Figma for developers indicating the equivalent REM values.
Use px to rem js snippets to automate conversion in your web apps. Here’s a simple example:
function pxToRem(px, base = 16) {
return `${px / base}rem`;
}
console.log(pxToRem(32)); // Outputs "2rem"
This is helpful in styled-components, dynamic styling, or any front-end framework.
For Sass/SCSS users, a sass rem function streamlines unit conversion in your stylesheets:
@function rem($px, $base: 16) {
@return ($px / $base) * 1rem;
}
body {
font-size: rem(18); // Outputs: 1.125rem
}
This ensures consistent scaling throughout your styles.
REM isnβt just for font size. You can also use REM to convert width and height for elements:
.container {
width: 30rem; /* 480px if base is 16px */
height: 10rem; /* 160px */
}
This improves layout scalability, especially on different screen sizes.
When working with nested components or legacy code, you might need to convert element EM to REM. EM depends on the parent, while REM references the root font size. For consistent scaling, convert EM to REM by tracing the hierarchy and recalculating.
Want to express REM units as percentages? Here’s how:
1rem (at 16px base) = 100% of root font size
0.75rem = 75%
Use rem to percentage
conversions to align text scaling with layout grids or fluid typography systems.