px
rem

Use our PX to REM converter to easily switch between pixel and REM units for responsive web design. Simplify your CSS font sizing today.

Pixels (PX) to REM

PixelsREM
1px0.0625rem
2px0.125rem
3px0.1875rem
4px0.25rem
5px0.3125rem
6px0.375rem
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
15px0.9375rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
25px1.5625rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
44px2.75rem
48px3rem
50px3.125rem
56px3.5rem
64px4rem
72px4.5rem
75px4.6875rem
80px5rem
90px5.625rem
100px6.25rem

REM to Pixels (PX)

We’re assuming the standard default browser font-size of 16px

REMPixels
0.01rem0.16px
0.03rem0.48px
0.05rem0.8px
0.08rem1.28px
0.1rem1.6px
0.15rem2.4px
0.2rem3.2px
0.5rem8px
1rem16px
2rem32px
3rem48px
4rem64px
5rem80px
6rem96px
8rem128px
10rem160px
15rem240px
20rem320px
30rem480px
40rem640px
50rem800px
60rem960px
80rem1280px
100rem1600px

A PX to REM Converter is a CSS conversion tool that turns a fixed pixel value into a rem value scaled against the root font size.

Designers and frontend developers run it during a handoff, converting spacing and typography values before they reach production CSS.

The output is measured against the font-size declared on the html element, since that value is what every rem calculation depends on.

71% of sites still declare font-size in pixels, the same share recorded in 2021, according to HTTP Archive’s 2022 Web Almanac.

That leaves most stylesheets unresponsive to a reader’s own font settings.

What Is a PX to REM Converter?

A px to rem converter takes a fixed pixel value and turns it into a rem value, using a base font size as the divisor.

The output scales with the root element’s font size instead of staying locked at a fixed pixel count.

What it accepts and returns:

  • Single values, like 24px or 1.5rem
  • Shorthand strings, like margin: 10px 20px
  • Bulk lists pasted straight from a stylesheet or a design file

The output comes back as a decimal rem value, rounded to a set number of places.

Same job, different point in the workflow. A designer might run one value through a quick tool, while a build pipeline runs the identical conversion automatically through a Sass mixin or a build step.

This sits squarely in frontend work.

It shapes how CSS length values get written, not how a server processes a request.

What Is the Difference Between px, rem, and em?

Pixels are an absolute unit tied to the screen, while rem and em are relative units tied to font size.

The difference between rem and em comes down to which font size each one reads from.

Px: a fixed length that ignores the reader’s font size preference and the parent element’s styling entirely.

Em: relative to the font size of its own parent, so nested elements compound the size with every level down.

Rem: relative only to the root element, so nesting has zero effect on the final size.

Compounding is the whole problem with em in deeply nested components. Rem exists specifically to avoid it.

The name explains itself once you see it spelled out: rem stands for root em, a detail that clears up a lot of confusion about how the two units diverge inside nested layouts.

Px is older and simpler. It’s short for pixel, and the term’s origin still shapes how most developers think about screen-based sizing today.

How Does px to rem Conversion Work?

The conversion depends on one number: the base font size sitting on the root element.

Change that number and every rem value on the page recalculates against it.

The Conversion Formula

The formula is a single division. Take the pixel value, divide by the base font size, and the result is the rem value.

A 24px heading divided by a 16px base comes out to 1.5rem.

Browsers set the root font size to 16px by default, a figure defined in the CSS Values and Units specification maintained by the W3C CSS Working Group.

Root Font Size and Base Font Size

Root font size and base font size mean the same thing in most projects: the font-size value set on the html element.

  • Left untouched, that value is 16px in every major browser
  • Some teams use the 62.5% trick, setting the root to 62.5% so 1rem equals 10px for easier mental math
  • A CSS reset or a third-party framework can quietly change it, throwing off every rem value downstream

Anyone converting values by hand should confirm the root font size before doing the math, not after.

Rounding and Decimal Precision

Common precision settings:

  • 3 decimals: the default in most PostCSS-based conversion plugins
  • 4 to 5 decimals: common in design-token pipelines chasing pixel-perfect parity
  • 2 decimals: fine for typography, too coarse for hairline borders

More decimals mean closer parity with the original pixel value, at the cost of longer numbers sitting in the stylesheet.

A rem value rounded too aggressively can drift a few tenths of a pixel from the design file. That rarely matters for body text, but it shows up fast on aligned grids.

Should You Use rem Instead of px?

Use rem for anything tied to reading comfort, and keep px for details that must never move.

The choice between the two units comes down to whether a value should respect the reader’s font size settings or ignore them outright.

When rem Is the Better Choice

Rem earns its place anywhere text or spacing needs to respond to the reader’s own settings.

Responsive typography depends on exactly this: font sizes that scale with the root value instead of sitting frozen at a fixed pixel count.

  • Body copy, headings, and line height
  • Spacing scales tied to a design system
  • Component padding that needs to breathe as text grows
  • Breakpoint widths, on the rare project that ties them to font size

When px Is Still Correct

Good fits for px:

  • Border widths on cards and inputs
  • Box shadow offsets and blur radius
  • Icon grids locked to a fixed pixel size

Forcing rem onto these properties adds complexity without a real benefit. It can also produce sub-pixel rendering that looks slightly blurry at odd zoom levels.

Does rem Improve Accessibility Compliance?

Rem supports one specific accessibility requirement: letting text resize based on the reader’s browser settings instead of a value locked in pixels.

WCAG Success Criterion 1.4.4, a Level AA requirement, calls for text that can be resized up to 200 percent without losing content or functionality, per the W3C’s Web Content Accessibility Guidelines.

A page built entirely in px can still pass that test, as long as the browser’s zoom scales everything at once.

It tends to fail the moment someone raises only the text-size setting, since fixed px values don’t answer to that control the way rem does.

What breaks with fixed px:

  • Text that ignores the browser’s font size preference
  • Line height locked in px, which causes overlapping text at larger sizes

None of this makes rem an accessibility feature by itself. Web accessibility covers far more ground than unit choice, from color contrast to keyboard navigation.

It does make accessible typography easier to reach, since the scaling behavior comes built in instead of being rebuilt with custom logic.

Which Browsers Support rem Units?

Every browser in active use today supports the rem unit, and has for well over a decade.

The unit reached Baseline widely available status on January 29, 2018, meaning it had run across major browsers long enough to use without fallbacks, per the web-features tracking published alongside MDN.

BrowserSupport SinceNotes
ChromeVersion 4 (2010)Full support, no known issues
FirefoxVersion 3.6 (2010)Full support, no known issues
SafariVersion 5 (2010)Full support, no known issues
EdgeVersion 12 (2015)Full support from launch
Internet Explorer9 partial, 11 fullIE 9 and 10 miss rem in the font shorthand and on pseudo-elements

That last row is the one that used to cause real trouble. IE 9 and 10 dropped rem values used inside the font shorthand property or applied to before and after pseudo-elements, a gap Microsoft closed in IE11.

None of this matters much today, since cross-browser compatibility concerns around rem effectively ended once Internet Explorer fell out of active use.

Which Conversion Method Works Best: Manual, Online Calculator, or Build Automation?

The right method depends on how many values need converting and how often the project changes.

MethodSetup EffortConsistencyBest For
Manual calculationNoneDepends on the person doing the mathA single one-off value
Online calculatorNoneHigh, if the base value stays fixedSmall batches, quick checks
Build automationOne-time setupHigh, enforced automaticallyFull projects, design systems

Manual Calculation

Dividing by hand works fine for a single value. It stops working the moment a stylesheet has more than a handful of sizes to convert.

The formula never changes, but doing it thirty times by hand invites arithmetic mistakes that are hard to spot during review.

Online Calculators

No setup required:

  • Paste a px value, get the rem equivalent right away
  • Good for spot-checking a design handoff before writing any code

These tools skip the setup that build automation needs, which is exactly why they’re the wrong fit for an entire codebase.

Build-Time Automation

postcss-pxtorem, a widely used PostCSS plugin, converts every px value in a stylesheet during the build step.

The plugin sees roughly 557,000 downloads a month across more than 1,600 dependent packages, according to npm registry usage data.

That scale of adoption reflects how routine it has become for larger teams to skip manual conversion entirely.

  • Runs automatically on every build, with no manual step to forget
  • Configurable root value, decimal precision, and which properties get converted
  • Pairs well with a Sass mixin for projects that lean on a preprocessor instead of a build plugin

How Do You Convert px to rem Step by Step?

Manual conversion is four steps, done in order, every time.

  • 1. Confirm the base. Check the root font-size value the project actually uses before touching any numbers.
  • 2. Divide. Take each px value and divide it by that base font size.
  • 3. Round. Apply one consistent decimal precision across the whole file, not a different one per value.
  • 4. Verify. Load the page at default zoom and compare the rendered size against the original design.

Skipping step one is the most common mistake. A project that quietly overrides the root font size will throw off every value converted against the wrong base.

Step four catches errors that math alone won’t. A rounding choice that looks fine on paper can still shift text by a visible amount once it renders.

How Do You Automate px to rem Conversion With Sass or PostCSS?

Automation removes the two weak points in manual conversion: forgetting a value and rounding it inconsistently.

Sass and PostCSS solve the same problem at different points in the workflow, one at the source file, one during the build.

Sass Mixin Setup

A rem mixin takes a pixel value, divides it by a stored base variable, and returns the result with a rem unit attached.

What the mixin needs:

  • A variable holding the base font size, usually 16
  • A function that performs the division and appends “rem” to the result
  • A way to call it inline, wherever a px value would normally sit

Older mixins wrote that division with a plain slash. Modern Sass treats bare slash division outside calc() as deprecated, and removes it entirely in Dart Sass 2.0.0, according to the official Sass documentation.

The replacement, math.div(), has shipped since Dart Sass 1.33.0 and returns an identical result.

The base variable should always match whatever font size actually sits on the HTML element, never a guessed value.

postcss-pxtorem Setup

The plugin installs through npm and runs as a step inside an existing PostCSS pipeline, no separate build tool required.

PostCSS itself runs on JavaScript, through Node, during the build rather than in the browser.

Its default propList only touches four properties: font, font-size, line-height, and letter-spacing, according to the plugin’s own documentation.

Everything else, including margin, padding, and width, stays in px until that list gets widened.

Typical configuration changes:

  • Setting propList to a wildcard, so every property converts
  • Raising or lowering rootValue to match the project’s base font size
  • Setting minPixelValue so tiny values like 1px borders stay untouched
  • Enabling conversion inside media queries, for breakpoints written in px

How Do Tailwind CSS and Bootstrap Handle rem-Based Sizing?

Both frameworks default to rem rather than px, and both build their scales to support responsive design without extra configuration.

Where they differ is how the scale gets generated and how far it reaches.

Tailwind CSS Configuration

Tailwind’s spacing and typography scales are built in rem from the ground up, not converted from px afterward.

Each step in the default spacing scale moves in increments of 0.25rem (4px), according to Tailwind’s own documentation.

  • p-4 renders as 1rem of padding, not a flat 16px value
  • text-base sits at 1rem for body copy

Changing the root font size shifts every utility class built on that scale at once, since none of them hold a fixed pixel value internally.

Bootstrap Typography Scale

ElementDefault Size
Body text1rem (16px)
h12.5rem (40px)
h31.75rem (28px)
h61rem (16px)

Every value in that table traces back to a single Sass variable, $font-size-base, which defaults to 1rem.

Change that one variable and Bootstrap recalculates its entire heading scale, since each heading size is defined relative to it rather than set independently.

The framework functions as a ready-made design system in this sense, with rem wired into its defaults instead of bolted on afterward.

What Goes Wrong When Converting px to rem?

Most rem problems trace back to a mismatch between what a developer assumes about the root value and what actually renders.

Common mistakes:

  • Assuming rem compounds like em inside nested components, then debugging a sizing issue that was never there
  • Converting every value in a file at once, including ones that were never meant to scale
  • Leaving a leftover px fallback in the stylesheet that silently overrides the rem value in some browsers

Border rendering has its own documented quirk. Rem-sized borders have been known to disappear when a page is zoomed out in Chromium-based browsers, a behavior noted in caniuse’s own compatibility notes for the unit.

That’s one more reason border widths tend to stay in px even on projects that convert everything else.

Mixing rounded and unrounded rem values in the same stylesheet creates a second, quieter problem.

A heading rounded to three decimals and a caption rounded to two can end up a fraction of a pixel apart, even when both started from the same original design value.

When Does px to rem Conversion Not Apply?

Rem conversion assumes a browser rendering a stylesheet. Several common situations don’t provide that.

Where rem doesn’t help:

  • Print stylesheets, where physical units like pt or in map more directly to paper output than a screen-relative unit
  • SVG coordinate attributes and canvas drawing calls, which take unitless numbers with no CSS length unit involved
  • Legacy codebases still targeting Internet Explorer 8 or earlier, which never implemented the rem unit
  • Design handoffs specifying exact pixel coordinates for a fixed-size export, like an app icon or a print-ready graphic

None of these are edge cases invented for the sake of completeness. They come up constantly on projects that mix web output with print, native apps, or older embedded browsers.

A project that converts everything to rem without checking these contexts first usually ends up converting a few values back to px later, in the one part of the codebase that never needed it.

FAQ on Px To Rem Converter

How Do Design Tools Like Figma Export Values That Need Conversion?

Figma exports frame and text measurements in raw pixel values by default, since its canvas works in absolute px coordinates. Developers convert those exported numbers to rem manually or through a plugin before dropping them into production CSS.

Do rem Units Affect SEO or Page Load Performance?

Rem adds no meaningful weight to a stylesheet and carries no direct ranking signal. Search engines don’t parse CSS units for relevance. Page speed depends on file size and render-blocking behavior, not on whether lengths are written in px or rem.

Is rem Better Than Other Relative Units Like Percent or vw?

Rem beats percent for typography since percent compounds through nested parents unpredictably. Viewport units like vw scale with screen width instead of font size, useful for fluid headlines but risky for body text, which needs a stable, readable baseline.

How Do You Verify a rem Conversion Is Rendering Correctly in DevTools?

Open the browser’s DevTools, select an element, and check the computed tab for its resolved pixel size. Change the root font-size temporarily in the same panel and confirm the element scales, proving the rem value is live, not hardcoded.

Can You Convert rem Back to px?

Yes. Multiply the rem value by the root font-size to get pixels back. A 1.5rem value on a 16px base returns 24px. The math runs in either direction, nothing about the conversion is one-way or destructive.

Do CSS Custom Properties Work With rem Values?

Yes. A custom property can store a rem value directly, like –spacing-unit: 1rem, and get reused across a stylesheet through var(). Changing the property updates every element referencing it, without touching each declaration individually.

What Should You Convert First With a Px to Rem Converter?

The first values worth running through a px to rem converter are the root typography settings, because every other rem calculation on the page inherits from that one base font-size declaration, not the spacing or border values further down the stylesheet.

  • Root font-size and typography
  • Spacing and layout scales
  • Borders, icons, and fixed-size details left in px

Typography errors show up immediately to every reader, while a wrong spacing value blends into the layout and gets caught later, if at all.

Converting type before spacing accepts one trade-off: a project runs two passes instead of one, since spacing choices often shift again once the type scale settles.

A px to rem converter pairs naturally with css viewport units, since width-based measurements track the screen instead of sitting fixed to one root font-size.

Bogdan Sandu
Latest posts by Bogdan Sandu (see all)