vasilenko.info

px, rem and em converter

/en/tool/px-rem-converter/ works Runs in the browser

Edit any field to recalculate the others: convert pixels to rem and back, or to em, percentages, points, and viewport units. Alongside it, replace all sizes in a CSS snippet, view a table of common values for your base font size, and generate a clamp() string for a size that grows with the screen.

promoTwenty years of notes on websitesHow we did it in 2008 and what still works today.Open

Recalculate size

The fields are equivalent: edit pixels to calculate rem, or edit rem to calculate pixels.

Base page font size

Browsers use 16 px by default. Choose another value only if you have overridden font-size for html in your styles.

font-size for html: rem is calculated from this and nothing else
Needed only for em and percentages: they are calculated from the nearest parent
The five fields below represent the same number in different units. Edit any field to recalculate the others.
Size from the design: font size, padding, radius—anything
Enter 1.375 here to see its pixel equivalent on the left
Calculated from the parent font size, not from html
Same as em, multiplied by 100
Needed for print styles: 1 px = 0.75 pt
Screen: for vw, vh, vmin, and the clamp() expression
Width at which the size equals the entered value. It is also the upper bound of clamp()
Needed only for vh and vmin
Lower bound of clamp(): the narrowest phone you support
Until you change the field, it shows three quarters of the base size — the usual difference between phone and desktop

Size in rem

rem

CSS line

This is what the reader will see if they increase the browser font size

at a base of 16 px
at a base of 18 px
at a base of 20 px
at a base of 24 px

Viewport units

vw
vh
vmin

One vw is a percentage of the screen width. A size set only in vw does not respond to the browser font setting: for font size, use it with rem inside clamp().

clamp() line: the size grows between two widths

Calculated from the “narrow screen” and “screen width” fields. Open in the clamp() generator — it has a chart, a font size scale, and WCAG checks.

Calculated in the browser. Neither sizes nor pasted CSS are sent anywhere: after loading, the page makes no requests.

How it looks

The same line set at the resulting size with three browser font settings. The size is set in rem, so it changes with the base size.

At a base of 16 px

Eat more of these soft French rolls

At a base of 20 px

Eat more of these soft French rolls

At a base of 24 px

Eat some more of these soft French rolls

Convert an entire CSS snippet

Paste your styles — all pixel values will become rem based on the selected base font size. Media query widths, quoted text, and URLs in url() remain unchanged.

Direction
border*, outline*, box-shadow, and text-shadow properties. A 1 px border should remain a border with larger text, not turn into a frame.
padding: 1.5rem 2rem /* 24px 32px */ — useful during review, but you will need to remove the comments before building.

The field is empty: paste your styles here, and the converted snippet will appear on the right.

Common sizes

The table updates with the base font size. Clicking a value copies it.

With a base of 16 px
SizeIn rem

promoCalculate ROI at the same timeCampaign payback based on spend and revenue.Open

How to use it

  1. Choose the base font size with a button or enter your own. If you have not overridden the font-size of html, leave it at 16 px—that is what browsers use.

  2. Then edit any of the five fields. If you know the size from a design, enter pixels. If you are reading someone else's CSS and want to understand its actual size, enter rem, em, or percentages, and the pixel value will be calculated automatically.

  3. Read the “what the reader will see” line as an accessibility check: it includes the full range of browser font-size settings, not just one step. The “How it looks” section shows the same thing visually.

  4. If you need more than one size and the entire file, paste a piece of CSS into the “Recalculate an entire piece of CSS” section. The borders and shadows checkbox leaves in pixels anything that would be harmful to convert to rem.

  5. The table of common sizes is recalculated for the selected base. Clicking a value copies it; the button next to it exports the entire table as --size-* variables or a file.

  6. The “Copy link” button puts all fields into the URL. You can send the link in a chat, and your colleague will see the same calculation. The settings are also saved in the browser until next time.

promoBrowser task listNo account required—everything is stored on your device.Open

The formula and what it includes

rem = px ÷ base font size · em = px ÷ parent font size · pt = px × 0.75 · vw = px ÷ screen width × 100

em is inherited and compounds: nested elements with font-size: 1.2em produce 1.2 × 1.2 = 1.44. rem does not compound this way—the reference point is always the same. The reverse calculation works the same way, with division replaced by multiplication: 1.375rem with a 16 px base equals 22 px.

Example breakdown: 24 px with a 16 px base

The input data is the same as the default field values: you can calculate it mentally and confirm that the tool is telling the truth.

  1. In rem: 24 ÷ 16 = 1.5.

  2. In em: 24 ÷ 20 = 1.2. The percentage is the same: 1.2 × 100 = 120%.

  3. In points: 24 × 0.75 = 18 pt. In vw at a width of 1440: 24 ÷ 1440 × 100 = 1.66667.

  4. If the reader increases the base font size to 20 px, an element set in rem will become 1.5 × 20 = 30 px, and at 24 px it will become 36 px.

  5. The reverse: to find out how many pixels are in 1.375rem, enter this number in the rem field—it will produce 22 px.

24 px with a 16 px base equals 1.5 rem. In styles: font-size: 1.5rem.

Frequently asked questions

promoAll toolsForty-four tools, all running in your browser.Open

Related tools

5