Start a project

Tool 12 of 29 · CSS

CSS Units Converter

Convert any CSS length between px, rem, em, viewport units and points, with your own root size and screen, or convert a whole stylesheet to rem at once.

CSS Units Converter

Convert a value

Context

1rem; browsers default to 16
For em and %

Equivalents

UnitValueCopy
All values

Convert a whole stylesheet from px to rem

Keeps 1px borders crisp
Converted CSS

01

What it does

Converts between px, rem, em, %, vw, vh, vmin, vmax and pt, and turns a whole stylesheet from px into rem.

  • Nine units, converted both ways
  • Your own root, parent and viewport sizes
  • One-click copy for each value
  • Whole-stylesheet px to rem conversion

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

Values and converted CSS, with a Copy and a Download button on every result.

  • rem
  • px
  • Viewport units
  • CSS

Why it matters

Sizes in rem follow the reader's chosen browser text size; sizes in px don't. Someone who sets larger text because of low vision gets bigger rem-based type and spacing, while a px-based layout ignores them. That's why most accessibility guidance recommends rem for font sizes.

Designs usually arrive in pixels, though, so converting is a constant chore. This tool does single values with your real context, and can convert an entire stylesheet in one go while leaving 1px borders alone.

How to use it

  1. Enter a value and choose its unit.
  2. Set the root font size (usually 16px), the parent size for em and %, and the viewport.
  3. Copy any equivalent from the table.
  4. To convert a stylesheet, paste it below and copy the result.

FAQ

Why is 16px equal to 1rem?

Browsers use 16px as the default root font size, so 1rem is 16px unless the site or reader changes it.

What's the difference between rem and em?

rem is relative to the root (html) font size, so it's the same everywhere. em is relative to the current element's font size, so it compounds inside nested elements.

Should media queries use rem?

em is the safest choice for media queries because it follows the reader's text size consistently across browsers. The converter can leave media queries alone if you prefer to keep px there.

How many pixels is 1pt?

1pt is 1/72 of an inch and 1px is 1/96 of an inch in CSS, so 1pt = 1.333px and 12pt = 16px.

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk