PX to REM / EM Converter
Convert a list of pixel values to rem or em, convert rem back to pixels, or paste a stylesheet and have every px value rewritten as rem.
Use the tool
Why this tool exists
Sizing in rem lets text and spacing follow the visitor's browser font size, which matters for accessibility. Designers still hand over pixel values, and doing the division by 16 in your head for every margin is slow and error-prone.
Set your root size, usually 16, and paste a list of values to get a table. Or paste CSS and the tool rewrites each px value, turning 0px into plain 0 and trimming long decimals. Note that em depends on the font size of the parent element, so the same number only equals rem at the root level. Media query widths and borders you want to keep sharp are better left in pixels, so check the rewritten CSS before shipping it.
How to use it
- Choose px to rem, rem to px, or rewrite CSS.
- Enter values one per line, or paste CSS, and set the root font size.
- Copy the converted values or the new stylesheet.
Frequently asked questions
What is the difference between rem and em?
rem is relative to the root element font size, em to the font size of the element or its parent. The tool divides by the root size, which is exactly right only for rem.
Does rewriting CSS change media queries?
Every px value in the pasted text is converted, including those in media queries. Browsers handle em and rem in queries differently from px, so you may prefer to restore those.
Why is 0px written as 0?
Zero needs no unit in CSS, so 0px becomes plain 0. Other values keep up to four decimals with trailing zeros removed.
What root size should I use?
16 matches the default in browsers. If your site sets html font-size to 62.5 percent, use 10 so the maths lines up with your CSS.