CSS Unit Converter

Convert values between px, rem, em, vw, and vh.

🔒 Client · Offline
Processed locally
This tool runs in the browser.

Base 1rem font size.

Base 1em font size.

Reference for 100vw.

Reference for 100vh.

Pixels (px)

16px

Root EM (rem)

1rem

Element EM (em)

1em

Viewport Width (vw)

0.8333vw

Viewport Height (vh)

1.4815vh

Snippet converter

Paste CSS to change each px length to rem. A 0px length becomes 0. A 1px length stays.

About CSS Units

Pixels (px) give an absolute length on a screen.

Root EM (rem) is relative to the font size of the HTML root element. The tool starts at 16 px, which is the default root font size of a browser.

Element EM (em) is relative to the font size of the parent element. The Parent Font Size field sets that value. Change it to a value other than the root font size, and the em result differs from the rem result.

Viewport Width (vw) and Viewport Height (vh) are relative to the viewport. The tool does not read your browser window. It uses the Viewport Width and Viewport Height fields, and they start at 1920 px and 1080 px. Change the fields to match your target screen.

The snippet converter changes each px length to rem with the Root Font Size value. A 0px length becomes 0, because a zero length needs no unit. A 1px length stays, because a hairline border in rem can blur or disappear. A px value in a comment, a string, or a url() stays.