Skip to main content

    PX to REM Converter

    Convert pixels to REM and EM units. Set a custom base font-size for accurate conversions.

    Free to use. Runs in your browser.

    Enter a pixel value to see the equivalent in rem, em, and percentage. Based on the default browser root font size of 16px, which you can customise.

    Use rem for text and spacing that should respect reader settings, and px for fixed details such as borders.

    8px0.500rem
    10px0.625rem
    12px0.750rem
    14px0.875rem
    16px1.000rem
    18px1.125rem
    20px1.250rem
    24px1.500rem
    28px1.750rem
    32px2.000rem
    36px2.250rem
    48px3.000rem

    Formula

    rem equals pixels divided by the root font size. With a 16px base, 24px becomes 1.5rem.

    Design handoff

    Designers often specify px values. Convert text, gaps, padding, and margins to rem before writing production CSS.

    Keep px for

    One-pixel borders, hairlines, shadows, and fine decorative details usually work best as fixed px values.

    Base-size warning

    Check your project before converting a large design system. A custom root font size changes every rem value, including third-party components.

    Common text sizes

    12px is 0.75rem, 14px is 0.875rem, 16px is 1rem, 18px is 1.125rem, and 20px is 1.25rem on a 16px base.

    Common spacing

    4px is 0.25rem, 8px is 0.5rem, 16px is 1rem, 24px is 1.5rem, and 32px is 2rem on a 16px base.

    These values match common spacing scales in Tailwind, shadcn-ui, and many design tokens.

    PX vs REM: Why It Matters

    Pixels (px) are fixed. 16px is always 16px regardless of the user's preferences. REM units are relative, 1rem equals whatever the root font size is (usually 16px by default). The difference seems small until you consider accessibility: millions of users increase their browser's default font size because they have difficulty reading small text.

    When you set font sizes, margins, and padding in rem, your entire layout scales gracefully when users change their browser settings. Set them in px, and increasing the font size can break layouts because the text grows but the containers don't. That's why CSS frameworks like Tailwind use rem-based spacing by default.

    This converter translates between px and rem using any base font size. The default is 16px (the browser standard), but if your project uses a different root font size, adjust the base to get accurate conversions.

    CSS Unit Comparison

    UnitRelative ToScales WithBest For
    pxNothing (absolute)NothingBorders, shadows, fine details
    remRoot font size (html)Browser settingsFont sizes, spacing, layout
    emParent font sizeParent elementComponent-level scaling
    %Parent dimensionParent sizeFluid widths and heights
    vw/vhViewport width/heightWindow sizeFull-screen layouts, hero sections
    chWidth of "0" characterFont choiceLimiting text width (max-width: 65ch)

    What this means for you: Use rem for most things (font sizes, padding, margins, gaps). Use px for things that shouldn't scale (1px borders, box shadows). Use vw/vh for viewport-relative layouts. Use ch for readable line lengths.

    Common PX to REM Conversions

    PixelsREM (base 16px)Tailwind ClassTypical Use
    4px0.25remp-1, gap-1Tight spacing, icon padding
    8px0.5remp-2, gap-2Small gaps, compact UI
    12px0.75remtext-xsCaption text, labels
    14px0.875remtext-smSecondary text, sidebar
    16px1remtext-baseBody text (browser default)
    20px1.25remtext-xlSubheadings
    24px1.5remtext-2xl, p-6Section headings, card padding
    32px2remtext-3xl, p-8Page headings, large spacing
    48px3remtext-5xlHero headings

    The 62.5% Trick

    Some developers set html { font-size: 62.5%; } to make 1rem = 10px (instead of 16px). This makes mental maths easier: 1.4rem = 14px, 2.4rem = 24px. But there are trade-offs:

    Pros

    • Easy mental conversion: 1.6rem = 16px
    • No calculator needed for common sizes

    Cons

    • Third-party components assume 16px base
    • Must reset body font-size to 1.6rem

    Conversion Formula and Examples

    The calculation is simple: divide the pixel value by the root font size. With the browser default of 16px, every 16 pixels equals 1rem.

    GoalCalculationCSS
    Convert 18px text18 / 16 = 1.125font-size: 1.125rem;
    Convert 24px padding24 / 16 = 1.5padding: 1.5rem;
    Convert 40px gap40 / 16 = 2.5gap: 2.5rem;
    Convert 12px label text12 / 16 = 0.75font-size: 0.75rem;

    If your root font size is 18px, the same 24px design value becomes 1.333rem instead of 1.5rem. Always check the project base before converting a full design.

    What to Convert and What to Leave Alone

    Use rem for text

    Body text, headings, captions, labels, and form controls should respond when a reader raises their browser font size.

    Use rem for spacing

    Padding, margins, gaps, and component rhythm usually feel better when they scale with the text they surround.

    Keep px for fixed details

    One-pixel borders, hairlines, small shadows, and icon strokes are often meant to stay visually fixed.

    Use other units for layout

    Percentages, grid fractions, container queries, and viewport units are better choices for widths and larger layout relationships.

    Design System Handoff Notes

    Design files often express everything in pixels because screens, frames, and exported measurements use pixels. CSS does not have to copy those units directly. Translate design intent into the unit that fits the job.

    Design SpecSuggested CSSReason
    16px body text1remMatches the browser default and scales with user settings
    14px helper text0.875remCommon secondary text size
    1px border1pxBorder should stay crisp and fixed
    24px card padding1.5remSpacing scales with the card's text
    720px content width45rem or 70chPick rem for layout scale, ch for readable prose width

    Testing REM-Based Interfaces

    Increase the browser font size

    Set the browser default to 18px or 20px and reload the page. Text, spacing, and form controls should grow without clipping or overlapping.

    Check small containers

    Bad conversions usually show up in buttons, badges, table cells, and sidebars first. Give fixed-format controls enough width or allow wrapping.

    Avoid converting every number blindly

    Converting a 1px border to 0.0625rem can make it change with the root font size. Use the design intent, not a mechanical rule.

    Document the base

    Record whether the project uses the browser default, a custom root size, or the 62.5% trick. Future conversions depend on that choice.

    Component-Level Example

    A button with 14px text and 12px vertical padding can become text-sm with 0.75rem padding. The border can stay 1px because it is a fixed visual detail.

    Design TokenPXREM CSS
    Button text14pxfont-size: 0.875rem;
    Vertical padding12pxpadding-block: 0.75rem;
    Horizontal padding16pxpadding-inline: 1rem;
    Border1pxborder-width: 1px;

    Related Tools

    How to use this tool

    1

    Enter a pixel value in the input field

    2

    Adjust the base font size if your project doesn't use the 16px default

    3

    See instant REM, EM, and percentage conversions

    Common uses

    • Converting pixel values to REM for accessible CSS
    • Building responsive layouts with relative units
    • Translating design specs (usually in px) to CSS rem values
    • Quick reference for Tailwind CSS spacing values

    Share this tool

    Frequently Asked Questions

    What is a REM unit?
    REM stands for 'root em'. 1rem equals the font-size of the root <html> element, which is 16px in all browsers by default. So 1.5rem = 24px, 0.5rem = 8px. REM units scale when users change their browser font size, making your layout accessible.
    Why use REM over PX?
    Millions of users increase their browser's default font size for readability. PX values ignore this preference, 16px stays 16px no matter what. REM values scale proportionally, so your entire layout adapts. It's the single biggest accessibility win in CSS.
    What is the difference between EM and REM?
    REM is always relative to the root <html> font size, predictable and consistent. EM is relative to the parent element's font size, which means nested elements compound. A 1.2em inside a 1.2em parent is actually 1.44em of the root. REM avoids this compounding problem.
    What's the default root font size?
    16px in current browsers. You can change it with html { font-size: 18px } or html { font-size: 62.5% } (makes 1rem = 10px for easier mental maths). Most Tailwind projects keep the 16px default.
    When should I use PX instead of REM?
    Use px for things that shouldn't scale with font size: 1px borders, box shadows, outline widths, and very small decorative details. If the element is content-related (text, spacing, layout), use rem. If it's decorative, px is fine.
    Does Tailwind use REM?
    Yes. Almost all Tailwind spacing and font size utilities use rem under the hood. p-4 is 1rem (16px), text-lg is 1.125rem (18px). Tailwind's design system is accessibility-friendly by default because of this. Only specific utilities like border widths use px.
    What happens if I change the root font size?
    Everything sized in rem scales proportionally. If you set html { font-size: 20px }, then 1rem becomes 20px, 0.5rem becomes 10px, and your entire layout grows by 25%. This is exactly the behaviour you want for accessibility.
    How do I convert my entire CSS from PX to REM?
    Divide every px value by your base font size (usually 16). So 24px becomes 24/16 = 1.5rem. For Tailwind projects, just use the utility classes, they're already in rem. For custom CSS, do the conversion during development, not at build time.
    What about viewport units (vw, vh)?
    Viewport units are relative to the browser window size, not font size. 1vw = 1% of viewport width. They're great for hero sections and full-screen layouts, but they don't respond to font size preferences. Use rem for text and spacing, vw/vh for layout dimensions.
    What is the 62.5% trick?
    Setting html { font-size: 62.5% } makes 1rem = 10px (62.5% of 16px). Then conversions are easy: 1.4rem = 14px, 2rem = 20px. The downside: it changes the base for everything, including third-party components. Most teams prefer the default 16px and memorise common conversions.
    Do all browsers support REM?
    Yes. REM has been supported since IE9 (2011). Current browsers support it. There is no reason to avoid rem in any current project. The only exception is email HTML, where support is inconsistent.
    What about the ch unit?
    ch equals the width of the '0' character in the current font. It's perfect for setting max-width on text containers: max-width: 65ch gives you optimal reading width regardless of font size. It's a complement to rem, not a replacement.

    Results are for general informational purposes only and should be checked before use. They are not professional advice. See our Disclaimer and Terms of Service.