Skip to CSS unit converter

CSS Unit Converter

Convert CSS lengths such as px, rem, em, %, vw, and vh with the font size and viewport context those units actually use.

CSS unit converter

Type 16px, 1.5rem, or font-size: 1.5rem. If you enter only a number, the fallback unit is used.

Presets

Typography scale: 12px, 14px, 16px, 18px, 20px, 24px. Spacing scale: 8px, 12px, 16px, 24px, 32px, 48px.

Conversion context

1rem = 16px. 1em = 16px.

Conversion viewport: 1440 × 900. Current browser viewport is read after the page loads. Presets are typical frames, not device truths.

Advanced units and viewport variants

ch, ex, cap, and lh need font metrics. The defaults are approximations until you measure the live font.

Primary result

1rem

REM depends on the root html font size (16px).

font-size: 1rem;

Core

  • px16px

    CSS reference pixel

  • rem1rem

    REM depends on the root html font size (16px).

  • em1em

    EM depends on the element's font-size context (16px).

  • %1.1111%

    % of the containing-block width.

  • vw1.1111vw

    VW depends on viewport width (1440px).

  • vh1.7778vh

    VH depends on viewport height (900px).

Advanced viewport

  • vmin1.7778vmin

    Smaller viewport dimension

  • vmax1.1111vmax

    Larger viewport dimension

  • svw1.1111svw

    Small viewport width

  • svh1.7778svh

    SVH uses the small viewport height (chrome visible).

  • lvw1.1111lvw

    Large viewport width

  • lvh1.7778lvh

    LVH uses the large viewport height (chrome hidden).

  • dvw1.1111dvw

    Dynamic viewport width

  • dvh1.7778dvh

    DVH depends on the dynamic viewport height.

Physical / print

  • in0.166667in

    1in = 96px

  • cm0.423333cm

    1in = 2.54cm

  • mm4.2333mm

    1cm = 10mm

  • Q16.9333Q

    1Q = 1/40cm

  • pt12pt

    1pt = 1/72in

  • pc1pc

    1pc = 12pt

Typography

  • ch2ch

    Width of the “0” glyph

  • ex2ex

    x-height of the font

  • cap1.4286cap

    Cap-height of the font

  • lh0.833333lh

    Used line-height

Live preview

Sample at 1440px simulated width — 16px equals 16px at this width.

Sample text
Bulk converter

    Calculations run in your browser. Values entered into the converter are not uploaded for normal use.

    CSS Unit Converter Quick Answer

    A CSS unit converter changes values between CSS length units such as px, rem, em, %, vw, vh, and physical units. Relative units need a context: root font size for rem, parent font size for em, and viewport dimensions for vw/vh. A CSS length converter does not invent a single px equivalent for every percentage.

    How to Use the CSS Unit Converter

    1. Enter a CSS value such as 16px or 1rem.
    2. Confirm the source unit if you typed a bare number.
    3. Adjust root font size, parent font size, or viewport settings when the unit is relative.
    4. Review all equivalent values, or switch to Pair converter for one target.
    5. Copy a result, a declaration, or the full list.
    6. Open Live preview to see font-size, padding, or width at a simulated viewport.

    CSS Unit Conversion Formulas

    • rem = px ÷ root font size
    • em = px ÷ parent/current font size
    • vw = px ÷ viewport width × 100
    • vh = px ÷ viewport height × 100
    • vmin = px ÷ min(width, height) × 100
    • vmax = px ÷ max(width, height) × 100
    • pt = px × 72 ÷ 96
    • in = px ÷ 96
    • cm = px × 2.54 ÷ 96
    • mm = px × 25.4 ÷ 96
    • Q = mm × 4

    Percentage conversion is property-specific. 50% width is not 50% font-size. CSS px is a reference unit, not automatically a device pixel.

    Examples

    • 16px → 1rem when the root is 16px.
    • 24px → 1.5rem when the root is 16px.
    • 32px → 2em when the parent/current font size is 16px.
    • 32px → 10vw at a 320px viewport.
    • 72px → 5vw at a 1440px viewport.
    • 12pt → 16px using the CSS 96px-per-inch reference.

    PX to REM Converter

    rem = pixels ÷ root font size. At the common 16px root, convert px to rem by dividing by 16. Change the root in the converter if your html font-size is not 16px.

    Pixels to rem at a 16px root
    pxrem
    8px0.5rem
    10px0.625rem
    12px0.75rem
    14px0.875rem
    16px1rem
    18px1.125rem
    20px1.25rem
    24px1.5rem
    32px2rem
    40px2.5rem
    48px3rem
    64px4rem

    REM to PX Converter

    px = rem × root font size. 1rem is 16px only while the root stays 16px.

    Rem to pixels at a 16px root
    rempx
    0.5rem8px
    0.625rem10px
    0.75rem12px
    0.875rem14px
    1rem16px
    1.125rem18px
    1.25rem20px
    1.5rem24px
    2rem32px
    2.5rem40px
    3rem48px
    4rem64px

    PX to EM and EM to PX

    em = px ÷ parent/current font size. px = em × that same context. rem and em match only when the parent font size equals the root. Nested em values compound; rem does not.

    Pixels to em at a 16px parent font size
    pxem
    8px0.5em
    16px1em
    20px1.25em
    24px1.5em
    32px2em

    PX to VW and VW to PX

    vw = px ÷ viewport width × 100. px = vw ÷ 100 × viewport width. 10vw is 144px at 1440px wide and 39px at 390px wide. 5vw at 390px is 19.5px. Use Pair converter when you only need px → vw.

    10vw at common viewport widths
    Viewport width10vw
    320px32px
    375px37.5px
    390px39px
    768px76.8px
    1024px102.4px
    1280px128px
    1440px144px

    PX to VH and VH to PX

    vh uses viewport height. 50vh at 800px tall is 400px. Do not use width when the unit is vh.

    CSS Units Reference

    CSS unit categories
    UnitCategoryRelative toCommon use
    pxReferenceCSS pixelBorders, hairlines
    remFont-relativeRoot font sizeType and spacing
    emFont-relativeParent font contextComponent sizing
    %ContextProperty-specificFlexible boxes
    vw / vhViewportWidth / heightFluid layout
    vmin / vmaxViewportMin / max dimensionResponsive effects
    svh / lvh / dvhViewportSmall / large / dynamic heightMobile chrome
    in / pt / cmPhysical96px per inchPrint / design export

    rem vs em

    rem is root-relative. em is context-relative. Neither is always better — rem keeps a scale stable; em can scale a whole component when the parent font size changes.

    rem compared with em
    remem
    Relative toRoot font sizeParent / current font context
    Typical useType scales and page spacingComponent-local padding and type
    ScalingChanges with the root onlyCompounds when nested
    Main advantagePredictable tokensA component can scale as one unit
    Potential issueIgnores local font-size unless you intend thatNested 1.2em × 1.2em grows faster than expected

    px vs rem

    px is a CSS reference length. It is useful for 1px borders and hairlines. rem follows the root font size, so typography and spacing can scale with user or theme settings. A CSS font size converter should not claim one is universally correct — use px when the size must stay fixed, rem when the scale should move with the root.

    vw, vh, svh, lvh, and dvh

    vw and vh use the classic viewport. svh is the small viewport (browser chrome visible). lvh is the large viewport (chrome hidden). dvh tracks the dynamic viewport as chrome shows and hides. On mobile, 100vh can overflow the visible area; 100dvh often matches the current height more closely. They are not identical, so pick the unit that matches the layout job.

    Physical CSS units

    in, cm, mm, Q, pt, and pc use the CSS reference of 96px per inch. 12pt equals 16px. 1pc equals 12pt. Q is a quarter-millimeter. These help when a design or print file exports inches or points. They should not dominate a screen stylesheet.

    Why CSS percentage conversion depends on context

    50% width uses the containing-block width. 50% font-size uses the parent font size. Percentage margin and padding, including top and bottom, also use containing-block width. This tool asks for a property context instead of inventing one px value.

    When to Use a CSS Unit Converter

    • Convert Figma or other design px values into rem or em
    • Build an accessible typography scale
    • Check viewport-based widths before a responsive pass
    • Translate print or design-tool measurements
    • Migrate a pixel stylesheet toward tokens

    For fluid min/max type that changes with the viewport, use the CSS Clamp Calculator after you know the endpoint units. That is a different job from converting a single length.

    Convert px, rem, em, vw, and vh

    Pair converter is the shortest path for convert px to rem, rem to px, px to em, em to px, px to vw, vw to px, px to vh, or vh to px. All units mode is the CSS units converter view when you want the full table, including a CSS viewport unit converter and print units such as pt and cm.

    Common mistakes

    1. Assuming 1rem is always 16px.
    2. Treating em and rem as the same unit.
    3. Converting % without a CSS property context.
    4. Using viewport width for a vh value.
    5. Treating 100vh as a reliable mobile full-screen height.
    6. Ignoring svh, lvh, and dvh on mobile chrome.
    7. Rounding too early, then comparing the rounded leftovers.
    8. Confusing CSS px with physical device pixels.
    9. Using pt on screen without the 96px-per-inch reference.
    10. Copying a converted value without checking it in the target layout.

    Frequently asked questions

    What is a CSS unit converter?

    It converts one CSS length into other units using the context those units require — root font size, parent font size, viewport size, or a percentage reference.

    How do I convert px to rem?

    Divide pixels by the root font size. At 16px root, 24px is 1.5rem. Change the root if html { font-size } is not 16px.

    How do I convert rem to px?

    Multiply rem by the root font size. 1.25rem × 16 = 20px.

    How do I convert px to em?

    Divide pixels by the parent or current font size, not automatically by the root.

    How do I convert em to px?

    Multiply em by that same parent/current font size.

    How do I convert px to vw?

    vw = px ÷ viewport width × 100. 144px is 10vw on a 1440px-wide viewport.

    How do I convert px to vh?

    vh = px ÷ viewport height × 100. Use height, not width.

    What is the default rem size?

    Browsers typically use a 16px initial font size, so 1rem is often 16px until you change the root.

    What is the difference between em and rem?

    rem is relative to the root. em is relative to the element’s font-size context and can compound in nested components.

    Can CSS percentages be converted to pixels?

    Only with a property context. 50% width uses the containing-block width. 50% font-size uses the parent font size. This tool will say context required instead of guessing.

    What is 1rem in pixels?

    1rem equals the root font size. That is 16px at the common default, or 18px if you set the root to 18px.

    What is 1em in pixels?

    1em equals the parent or current font size used as context. It is not locked to 16px.

    What is 1vw in pixels?

    1vw is 1% of the viewport width. On 1440px that is 14.4px. On 390px it is 3.9px.

    What is the difference between vw and vh?

    vw is a percentage of viewport width. vh is a percentage of viewport height.

    What are svh, lvh and dvh?

    They are modern viewport-height units. svh is the small viewport, lvh the large viewport, and dvh the dynamic viewport that tracks mobile browser chrome.

    What are vmin and vmax?

    vmin is 1% of the smaller viewport dimension. vmax is 1% of the larger one.

    Can I use this CSS converter for print units?

    Yes. in, cm, mm, Q, pt, and pc use the CSS reference of 96px per inch. That is a CSS reference, not a measured printer DPI.

    Does this CSS Unit Converter work on mobile?

    Yes. Results stack as cards on small screens. You can also load the current viewport.

    Is the calculation performed in the browser?

    Yes. Values stay on your device during normal use and are not uploaded.