PX to REM Converter - Free, Instant, Bidirectional | BotGauge

Enter any pixel value and get the exact rem equivalent, instantly. Supports custom root font size, batch conversion for multiple values at once, and bidirectional conversion.

px
rem
px

Conversions use 16px as the root font size, which is the browser default. If your CSS sets a different value on <html>, update the base field above and the results will adjust automatically.

Live Preview

Font Size = 0rem | Base Font Size = 16px

The quick brown fox jumps over the lazy dog.

The sample text renders at the converted rem size in real time, so you can see exactly how it will look on the page.

PX to REM Conversion Table

Three tabs: Font sizes, Spacing & padding, and Breakpoints. All values use 16px as the base, shown to 4 decimal places.

Font sizes

PXREM
10px0.625rem
11px0.6875rem
12px0.75rem
13px0.8125rem
14px0.875rem
15px0.9375rem
16px1rem
17px1.0625rem
18px1.125rem
19px1.1875rem
20px1.25rem
21px1.3125rem
22px1.375rem
24px1.5rem
26px1.625rem
28px1.75rem
30px1.875rem
32px2rem
36px2.25rem
40px2.5rem
48px3rem
56px3.5rem
60px3.75rem
64px4rem
72px4.5rem
80px5rem
96px6rem

Spacing & padding

PXREM
4px0.25rem
8px0.5rem
12px0.75rem
16px1rem
20px1.25rem
24px1.5rem
28px1.75rem
32px2rem
40px2.5rem
48px3rem
56px3.5rem
64px4rem
80px5rem
96px6rem
112px7rem
128px8rem
160px10rem
192px12rem
256px16rem
320px20rem
384px24rem

Breakpoints

PXREMCommon use
320px20remMobile small (iPhone SE)
375px23.4375remMobile default (iPhone 14)
480px30remMobile landscape
640px40remLarge mobile/small tablet
768px48remTablet portrait
1024px64remTablet landscape/small desktop
1280px80remDesktop standard
1440px90remDesktop large
1536px96remDesktop XL
1920px120remFull HD

Breakpoints in rem respond to users' browser font-size preferences.

How to convert PX to REM

The formula has one step:

rem = px ÷ root font size

Most browsers default to 16px. So divide any pixel value by 16. Example:

  • 20px to rem: 20 ÷ 16 = 1.25rem
  • 18px to rem: 18 ÷ 16 = 1.125rem
  • 14px to rem: 14 ÷ 16 = 0.875rem
  • 24px to rem: 24 ÷ 16 = 1.5rem

If you've set a custom root font size, say html { font-size: 18px }, divide by 18 instead. The tool handles this automatically when you change the base value above.

The 62.5% root font size trick

Set your root font size to 62.5%, and 1rem becomes exactly 10px.

html {
  font-size: 62.5%; /* 1rem = 10px */
}

body {
  font-size: 1.6rem; /* Reset body back to 16px */
}

The math gets trivial

20px becomes 2rem. 14px becomes 1.4rem. 36px becomes 3.6rem. No calculator needed mid-session.

One thing to know: users who have set their browser's default font size above 16px will have that preference compressed. 62.5% of 20px is 12.5px, so their 1rem is now 12.5px instead of the 20px they configured. If you use this trick, test your layout with browser font sizes at 20px and 24px, not just the default. The tool above has a "Use 62.5% base" toggle that automatically switches the converter to a 10px root.

PX vs REM vs EM: what's the difference?

Three CSS length units. Pick the wrong one, and you'll spend an afternoon debugging why a nested component came out 1.728× bigger than it should be.

PX

Pixels (px) are absolute. font-size: 16px is 16px everywhere: every screen, every context, regardless of what the user has configured in their browser. For typography, that rigidity is the problem.

REM

Root EM (REM) is relative to the root <html> element's font size. If the browser default is 16px and you haven't changed it, 1rem = 16px. Change the root, and every rem value scales with it. Rem respects what users configure in their browser settings. That's the key difference.

EM

EM is relative to the parent element's font size. Useful for self-contained components where you want everything to scale together. Dangerous in deeply nested layouts, because it compounds. A <span> inside a <li> inside a <ul>, where each element has font-size: 1.2em, ends up at 1.2 × 1.2 × 1.2 = 1.728× the root size. That's the bug.

PXREMEM
Relative toNothing (absolute)Root <html> font sizeParent element font size
Responds to browser preferencesNoYesDepends on parent
Compounds when nestedNoNoYes
Predictable across componentsYesYesNo
Best forBorders, shadows, fixed chromeTypography, spacing, layoutComponent-scoped sizing
WCAG 1.4.4 compliance (text resize)Fails for font sizesPassesPasses if root is rem

When to use PX

PX belongs on things that shouldn't scale with text: borders, box shadows, and fixed-width UI elements like a sidebar that's always 240px wide.

For font sizes, padding, margins, and gaps (anything related to readability and layout), rem is almost always the better choice. Media query breakpoints are worth converting to rem, too.

Why use REM in CSS?

Accessibility: WCAG 2.2 success criterion 1.4.4

WCAG 2.2 SC 1.4.4 (Resize Text, Level AA) requires that text can be resized up to 200% without losing content or functionality. Pixel-based font sizes fail this. They don't respond to browser default font size settings, so a user who needs larger text and configures their browser accordingly gets no benefit from a px-based stylesheet.

Rem-based font sizes pass because they scale with the root. A user who sets their browser default to 24px visits a rem-based page, and every font size scales up proportionally. That's what WCAG SC 1.4.4 requires.

About 1 in 4 adults in the US lives with some form of disability, and text resizing is one of the most common browser-level accessibility tools. Rem supports those users without any extra code.

Design systems that scale

When everything is in rem, a single CSS change cascades throughout the site. Update html { font-size: 18px } and your entire type scale, spacing, and layout shifts proportionally. No find-and-replace across dozens of files.

Design systems and token-based workflows (Tokens Studio, Style Dictionary) output rem values for exactly this reason. Figma designs in px. Production CSS needs rem. Converting at the handoff keeps everything consistent.

Responsive layouts and media queries

Media queries in rem respond to a user's browser preferences. @media (min-width: 48rem) triggers at 768px when the browser default is 16px. If a user has set their browser to 20px, that breakpoint fires at 960px. More space for larger text.

@media (min-width: 768px) always fires at 768px, regardless of browser settings. Rem breakpoints give you accessible, preference-aware behavior at no extra cost.

Tailwind CSS PX to REM mapping

Tailwind uses a 4px (0.25rem) base spacing unit. Every spacing class (padding, margin, width, gap) is a multiple of that. Font sizes follow a separate scale. Tailwind's built-in classes are already in rem. Use this table for custom values or when translating a Figma design that's still in pixels.

Typography scale

Tailwind classPXREM
text-xs12px0.75rem
text-sm14px0.875rem
text-base16px1rem
text-lg18px1.125rem
text-xl20px1.25rem
text-2xl24px1.5rem
text-3xl30px1.875rem
text-4xl36px2.25rem
text-5xl48px3rem
text-6xl60px3.75rem
text-7xl72px4.5rem
text-8xl96px6rem
text-9xl128px8rem

Spacing scale (padding, margin, gap, width, height)

Tailwind classPXREM
0 (p-0, m-0, gap-0)0px0rem
1 (p-1, m-1, gap-1)4px0.25rem
28px0.5rem
312px0.75rem
416px1rem
520px1.25rem
624px1.5rem
728px1.75rem
832px2rem
936px2.25rem
1040px2.5rem
1144px2.75rem
1248px3rem
1456px3.5rem
1664px4rem
2080px5rem
2496px6rem
28112px7rem
32128px8rem
36144px9rem
40160px10rem
44176px11rem
48192px12rem
52208px13rem
56224px14rem
60240px15rem
64256px16rem
72288px18rem
80320px20rem
96384px24rem

Add custom rem-based sizes in tailwind.config.js

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      fontSize: {
        'display-sm': '2.25rem',  // 36px
        'display':    '3rem',     // 48px
        'display-lg': '3.75rem',  // 60px
        'hero':       '4.5rem',   // 72px
      },
      spacing: {
        '128': '8rem',   // 128px
        '144': '9rem',   // 144px
      }
    }
  }
}

Advanced features of the PX to REM converter

Fluid typography with CSS clamp()

Modern CSS lets you set a font size that scales smoothly between a minimum and maximum without any media queries. clamp() takes 3 arguments: minimum size, preferred (fluid) size, maximum size.

font-size: clamp(1rem, 2.5vw + 0.5rem, 1.5rem);

This scales from 16px (1rem) on narrow screens up to 24px (1.5rem) on wide screens, with a fluid curve in between. No breakpoint jumps.

How to use the converter for clamp()

  1. Decide your minimum size in px. Convert to rem: 16px ÷ 16 = 1rem.
  2. Decide your maximum size in px. Convert to rem: 24px ÷ 16 = 1.5rem.
  3. Build your clamp expression: clamp(1rem, [preferred], 1.5rem).
  4. Tune the preferred value. 2.5vw + 0.5rem is a solid starting point for headings.

The batch converter handles steps 1 and 2 at once: paste your min and max px values, get both rem equivalents, then slot them into the expression.

CSS custom properties/design tokens output

After batch conversion, export a full :root block with named CSS variables:

:root {
  /* Spacing */
  --spacing-1:  0.25rem;   /*  4px */
  --spacing-2:  0.5rem;    /*  8px */
  --spacing-3:  0.75rem;   /* 12px */
  --spacing-4:  1rem;      /* 16px */
  --spacing-6:  1.5rem;    /* 24px */
  --spacing-8:  2rem;      /* 32px */
  --spacing-12: 3rem;      /* 48px */
  --spacing-16: 4rem;      /* 64px */

  /* Typography */
  --font-sm:   0.875rem;   /* 14px */
  --font-base: 1rem;       /* 16px */
  --font-lg:   1.125rem;   /* 18px */
  --font-xl:   1.25rem;    /* 20px */
  --font-2xl:  1.5rem;     /* 24px */
}

Paste directly into your CSS, or feed it into Style Dictionary as a JSON token source. Naming follows the Tailwind spacing scale by default; rename variables before copying if you need a different convention.

Common mistakes when using REM in CSS

Using rem for borders

Borders shouldn't scale with text. Keep border: 1px solid. If you write border: 0.0625rem solid, a user zoomed to 200% gets a 2px border. That's probably not what you designed. Same goes for box shadows and outlines, keep those in px too.

Changing the root font size and forgetting the downstream effects

Setting html { font-size: 14px } shifts your entire rem baseline from 16px to 14px. Every converted value in your stylesheet now computes slightly smaller than you designed.

If you worked from a 16px base in Figma and converted to rem, those values are now off. Keep the root at 16px (or use a percentage like font-size: 87.5% for 14px) and reconvert only the values that need to change.

Confusing rem with em

Both have "em" in the name. The difference is what they reference. Em is relative to the parent element. It compounds when nested. Rem always references the root <html> element, regardless of nesting depth. If you're seeing unexpectedly large font sizes in nested components, compounded em values are likely the culprit. Switch to rem for predictability.

Testing only at the browser default

Most developers test at 100% zoom with the browser set to 16px. Rem layouts look great. Now go to Chrome settings, set the default font size to 20px or 24px, and reload. If text overflows, containers collapse, or layouts break, that's a real bug that users with accessibility needs will hit. Test at larger browser font sizes during development, not just before launch.

Pixel breakpoints in media queries

@media (min-width: 768px) ignores browser font size preferences entirely. @media (min-width: 48rem) respects them. For accessible, preference-aware layouts, use rem breakpoints.

Summary

A rem-based font size that looks perfect at 16px can reflow containers and overflow text when a user has set their browser to 20px. Most developers never test this. And most never catch it until someone files a bug.

BotGauge catches visual regressions before users do. It runs automated tests across real browsers and screen sizes, flags what breaks, and tells you exactly where. Ship with confidence instead of crossing your fingers on deploy day.

Frequently asked questions

What is the rem unit in CSS?
Rem stands for Root EM. It's a relative CSS length unit, specifically relative to the font size of the root <html> element. Most browsers default to 16px, so 1rem = 16px unless you've changed it. Unlike px (which is fixed) or em (which compounds with nesting), rem always references the same value across your entire stylesheet. That predictability is why rem works well for typography, layout, and component sizing.
What is 20px in rem?
20px = 1.25rem at the default root font size of 16px. Formula: 20 ÷ 16 = 1.25. If your root font size differs, divide 20 by that value instead. At an 18px root: 20 ÷ 18 = 1.1111rem. At a 10px root (using the 62.5% trick): 20 ÷ 10 = 2rem.
What is 18px in rem?
18px = 1.125rem at the default root font size of 16px. Formula: 18 ÷ 16 = 1.125. A common value for large body text, H6 headings, or the minimum accessible font size in many design systems. At a 10px root (using the 62.5% trick): 18 ÷ 10 = 1.8rem.
Is rem better than px for accessibility?
Yes, for typography and spacing. WCAG 2.2 SC 1.4.4 requires text to be resizable up to 200% without loss of content or functionality. Pixel-based font sizes don't respond to browser default font size settings, so users who configure larger text in their browser see no change on a px-based site. Rem-based font sizes automatically scale with browser preferences, which is why they meet the criterion. For borders and fixed chrome, px is still fine.
What is the difference between rem and em?
Both are relative CSS units. Em is relative to the parent element's font size, which compounds when nested. Rem is always relative to the root <html> element, regardless of nesting depth. For typography across a full page or design system, rem is almost always the safer choice. Em is useful when you want a component's internal sizing to scale together, such as icon size relative to the button text next to it.
What is the default root font size in browsers?
16px. Chrome, Firefox, Safari, and Edge all default the root <html> element to 16px unless the user changes it in browser settings or you override it in CSS. That's why 1rem = 16px is the standard starting point for px-to-rem conversions and the default used by this tool.
Can I use rem for padding and margin, not just font size?
Yes, and you should. Using rem for padding, margin, and gap means your spacing scales proportionally with typography. If a user has increased their browser's default font size, your layout breathes more, which is usually exactly what they need for readability. The exceptions are borders and genuinely fixed-width chrome, like a navigation sidebar. Everything else connected to content density benefits from rem.
Building a responsive layout? BotGauge tests how it renders across real screen sizes