TapCub is live — analytics, insights and live chat, free on one platform

Free tool PX to REM converter for single values and whole stylesheets

Set your root font size, type a value in any unit and read all the others. Then paste a block of CSS or SCSS and convert every px value in one go, leaving comments, selectors, URLs and hairline borders alone.

  • px, rem, em, pt, vw, rpx
  • Batch CSS conversion
  • Your CSS stays local

Convert px and rem

Change the root size to match your project; every value and the table update.

Converter

The font size of the html element. Browsers default to 16 px.

Used for vw and rpx.

Trailing zeros are dropped.

Root size
24px = 1.5rem when the root font size is 16px

Convert a block of CSS

Paste CSS, SCSS or Less, or open a file. Write PX in capitals to keep a single value as it is.

Values this small stay in px, for example 1 for hairline borders. 0 converts everything.

converted.css
.card {
  padding: 1.5rem 2rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

@media (min-width: 768px) {
  .card { padding: 2.5rem; }
}

6 value(s) converted. 1 left as they were because of your settings.

PX to REM table

PixelsREMPointsPercent
1px0.0625rem0.75pt6.25%
2px0.125rem1.5pt12.5%
4px0.25rem3pt25%
6px0.375rem4.5pt37.5%
8px0.5rem6pt50%
10px0.625rem7.5pt62.5%
12px0.75rem9pt75%
13px0.8125rem9.75pt81.25%
14px0.875rem10.5pt87.5%
15px0.9375rem11.25pt93.75%
16px1rem12pt100%
18px1.125rem13.5pt112.5%
20px1.25rem15pt125%
22px1.375rem16.5pt137.5%
24px1.5rem18pt150%
28px1.75rem21pt175%
30px1.875rem22.5pt187.5%
32px2rem24pt200%
36px2.25rem27pt225%
40px2.5rem30pt250%
48px3rem36pt300%
56px3.5rem42pt350%
64px4rem48pt400%
72px4.5rem54pt450%
80px5rem60pt500%
96px6rem72pt600%
128px8rem96pt800%

Root rule

Only needed if you set the root size yourself. A percentage keeps the visitor’s browser font setting working.

CSS
html {
  font-size: 100%; /* 16px */
}
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Use this tool often? Save it to My tools.Saved to My tools. Find it any time at the top of the free tools page. You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.

Problem or suggestion?Send feedbackChat with support

Version v1.0Updated Update history

Read the result

What each unit is relative to

px is fixed within the page; the others scale with something.

  • Two-way, any root font size
  • Batch convert CSS and SCSS
  • Reference table
PX to REM converter illustration: Convert px to rem and back with any root size, rewrite a whole stylesheet at once, and get em, pt, vw and rpx values
PX to REM converter, illustrated

rem

Relative to the font size of the root element. If the root is 16 px, 1.5rem is 24 px. When a visitor raises the browser’s default font size, rem sizes grow with it.

em

Relative to the font size of the element itself (for font-size, of its parent). It compounds when nested, which rem does not.

pt

A print unit. In CSS 1pt is 1/72 inch and 1px is 1/96 inch, so 12pt equals 16px.

vw and rpx

1vw is 1% of the viewport width. rpx is used in WeChat mini programs, where the screen is always 750rpx wide.

In media queries, rem refers to the browser’s default font size, not to a size you set on html. That is one reason to leave breakpoints in px unless you want them to follow user settings.

How to use it

Convert a design into rem

Three steps for a single value or a whole file.

  1. 1

    Set the root size

    Use 16 unless your stylesheet changes the html font size. With the 62.5% trick the root is 10 px.

  2. 2

    Check single values

    Type the pixel value from the design file and copy the rem value.

  3. 3

    Convert the stylesheet

    Paste the CSS, choose what to keep in px, then copy or download the result and review it in your project.

Formula

PX to REM formula

rem = px ÷ root font size. The reverse is px = rem × root font size.

  • At a 16 px root: 16px = 1rem, 24px = 1.5rem, 14px = 0.875rem
  • pt = px × 72 ÷ 96
  • vw = px ÷ viewport width × 100
  • rpx = px × 750 ÷ screen width
  • Zero is written without a unit; comments, strings, selectors and url() are never changed

px → rem

rem = px ÷ root

24 ÷ 16 = 1.5rem

rem → px

px = rem × root

2.25 × 16 = 36px

px → vw

vw = px ÷ viewport × 100

30 ÷ 375 × 100 = 8vw

Worked example

Converting a card component

The default sample, with a 16 px root and 1 px values left alone.

Declarations before and after
DeclarationBeforeAfterWhy
padding24px 32px1.5rem 2rem24 ÷ 16 and 32 ÷ 16
border1px solid1px solidAt or below the 1 px limit
border-radius12px0.75rem12 ÷ 16
font-size14px0.875rem14 ÷ 16
line-height20px1.25rem20 ÷ 16
@media (min-width: 768px)768px768pxMedia queries are off by default
padding inside the query40px2.5rem40 ÷ 16

Six values are converted and one is left in px. Turn on “Also convert media queries” and the breakpoint becomes 48rem.

Common mistakes

Pitfalls when moving to rem

rem is useful because it follows user settings; these habits defeat that.

Setting html to a fixed pixel size

html { font-size: 16px } overrides the visitor’s browser setting. Leave it alone or use a percentage.

Forgetting a changed root

If one stylesheet sets the root to 62.5%, converting with base 16 makes everything 62.5% of the intended size.

Converting hairlines

A 1 px border turned into 0.0625rem can round to nothing or look uneven. Keep very small values in px.

Using em where you mean rem

Nested em font sizes multiply: three levels of 1.2em give 1.728 times the base.

FAQ

PX and REM questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

How many rem is 16px?

1rem, as long as the root font size is the browser default of 16 px. With a 10 px root it would be 1.6rem.

Should I use px or rem?

rem for font sizes and usually for spacing, so layouts respect the reader’s font setting. px is reasonable for borders, shadows and other details that should not grow.

How do I convert a 375 or 750 px mobile design?

If the root size is set to one tenth of the design width, use 37.5 for a 375 design or 75 for a 750 design. If you prefer viewport units, enter the design width as the viewport and copy the vw value: 30 px on a 375 design is 8vw.

What is the 62.5% trick?

Setting html { font-size: 62.5% } makes 1rem equal 10 px at default settings, so 24 px is 2.4rem. Remember to set a readable size on body afterwards, and check third-party components that assume 16 px.

Can I convert a whole CSS file?

Yes. Open a file or paste it into the batch box. The converter changes values in declarations, and leaves comments, strings, selectors, url() and anything written as PX or Px untouched.

How does it compare with postcss-pxtorem?

The idea is the same: divide by a root value and keep small or capitalised values. A build plugin is the better choice for an ongoing project; this page is for one-off conversions and checking numbers.

Is my CSS uploaded?

No. It is converted in your browser. The CSS is not stored, put in the share link or included in analytics.

Feedback

Is this tool working for you?

Rate it, or tell us what went wrong and what you’d like improved. A person reads every message, and frequent requests go into the next update.

Rate this tool

Please don’t include passwords or other sensitive information.

Only used to reply to this feedback.

Type, details and email are required.

We only use this to handle your feedback. See the privacy policy.

Feedback received

Thank you! We will read it and reply from hello@tapcub.com if needed.

Need help right now?

Chat with our support team, best for urgent problems; you can leave a message when we are offline.

Chat with support
Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

Cite this tool

Recommend this tool in an article or on your site

This tool is free to cite and share. Copy the URL or link below into your article, tutorial or resource page; to write a review, embed a tool or partner with us, get in touch.

URL
https://tapcub.com/tools/px-to-rem-converter
HTML link
<a href="https://tapcub.com/tools/px-to-rem-converter">PX to REM converter - TapCub</a>

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics