UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

About·Changelog·Privacy Policy·Terms of Service·Contact
HomeLayout & TypographyCSS Unit Converter

Related Tools

Type Scale Generator

CSS Unit Converter — px to rem, em & vw

Convert px to rem, em, %, vw, vh, pt and more with your own root font size and viewport, see a px to rem table, and convert a whole stylesheet in one go.

You Might Also Like

All Layout & Typography

Type Scale Generator

Build a modular type scale from Major Third, Perfect Fourth, Golden Ratio and more. Export CSS variables, Tailwind fontSize config or SCSS variables instantly.

URL Encode

Encode and decode URLs using encodeURI, encodeURIComponent, or raw percent-encoding. Includes common character reference table.

Gradient Generator

Generate linear, radial, and conic CSS gradients visually. Add unlimited color stops, adjust angles, use presets, copy ready CSS.

Regex Tester

Test regular expressions live with highlighted matches, capture groups, and a plain-English breakdown of every token. Includes replace preview and flag toggles.

Design files come in pixels, and accessible stylesheets are written in rem. Type a length here and read it in all 14 CSS units at once, worked out with your project’s own root font size and viewport instead of an assumed 16px and a guessed screen.

It opens on 24px, which is 1.5rem at the usual 16px root, and below that sits a real stylesheet ready to convert, a small .checkout-panel component.

How to Use the Converter and Stylesheet Mode

  1. Type a number and pick the unit it is in. Every other unit updates as you type, each with its own copy button.
  2. Set Root font size, Parent font size and the viewport to match your project. Open the px to rem table for the common sizes.
  3. Paste CSS under Convert a whole stylesheet, choose px → rem or rem → px, and copy the result.

Stylesheet mode is the part most converters lack. It leaves comments, strings and url() paths alone, so a file called hero-24px.png keeps its name, and it keeps values under Keep px below, 2px by default, because a 1px border should stay crisp when a reader enlarges their text. The label above the output counts the values it changed.

How the Math Works for Each Unit

Every conversion goes through CSS pixels. Rem divides by the root font size, so 24 ÷ 16 = 1.5. Em and % use the parent font size, and vw and vh are one hundredth of the viewport, so at 1440 wide 10vw is 144px. Physical units are fixed by the CSS specification at 1in = 96px, which makes 1pt = 1.3333px and 1cm = 37.7953px. That is a rule for the browser, not a ruler: on screen an inch of CSS is rarely a real inch. It only matches on paper.

Edge Cases: Zero, Hairlines and Media Queries

0px is left as it is. Results are rounded to 4 decimals here, and 2 to 6 in stylesheet mode. Leave @media conditions alone is on by default, so min-width: 768px stays put; turn it off and that becomes 48rem. Em in a real page compounds through nesting, so the parent size you enter holds for one element only. A blank box or a size of 0 shows “Font sizes and viewport sizes must be above 0.”

From

px
px
px
px
  • 24px
  • 1.5rem
  • 1.5em
  • 150%
  • 1.6667vw
  • 2.6667vh
  • 2.6667vmin
  • 1.6667vmax
  • 18pt
  • 1.5pc
  • 0.25in
  • 0.635cm
  • 6.35mm
  • 25.4Q
px to rem table at 16px root
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
48px3rem
56px3.5rem
64px4rem
72px4.5rem
80px5rem
96px6rem

Convert a whole stylesheet

Uses the root font size above. Comments, strings and url() paths are left alone.