Home › Developer Tools › PX to REM Converter

PX to REM Converter

Type a value in px, rem or em and the other units update instantly. Change the root font size if your site doesn't use 16px, grab values from the 1-100px table, or paste a whole stylesheet to convert every px value at once.

Last updated:

px
px

PX to REM table (base 16px)

Click a cell to copy its rem value.

Convert CSS

Advertisement
Advertisement

How to use the PX to REM Converter

  1. Set the root font size. Browsers use 16px by default. If your CSS sets html { font-size: 62.5% }, use 10.
  2. Type a value in the PX, REM or EM box. The other two boxes update immediately.
  3. Need em? Set the parent element's font size; em is relative to the parent, rem to the root.
  4. Use the table for quick lookups. Click any cell to copy its rem value.
  5. Convert a stylesheet: paste CSS into the converter below, choose the options and copy or download the converted CSS.

PX to REM formula

A rem ("root em") is a multiple of the font size of the root <html> element. Browsers set that root size to 16px unless the visitor or your CSS changes it, so:

  • rem = px ÷ root font size   e.g. 20px ÷ 16 = 1.25rem
  • px = rem × root font size   e.g. 2.5rem × 16 = 40px
  • em = px ÷ parent font size   e.g. 12px inside an 18px parent = 0.6667em

If your stylesheet sets html { font-size: 62.5%; }, the root becomes 10px (62.5% of 16px) and 1rem = 10px. Set the root size above to 10 to match.

Common px to rem values (16px root)

PixelsREMTypical use
8px0.5remSmall gaps, icon spacing
12px0.75remCaptions, fine print
14px0.875remSecondary text, buttons
16px1remBody text (browser default)
18px1.125remLarge body text, lead paragraphs
20px1.25remSmall headings
24px1.5remh3 headings, card padding
32px2remh2 headings, section spacing
48px3remh1 headings, hero spacing
64px4remDisplay text, large layout gaps

rem vs em vs px: which should you use?

rem is the safest choice for font sizes and most spacing: every rem value on the page is based on the same root size, so it is predictable, and it grows when a visitor raises their browser's default font size. em is useful when something should scale with its own component, such as padding on a button that grows with the button's text, but nested em values multiply (1.2em inside 1.2em is 1.44 times the root). px is still fine for things that should not scale, like 1px borders, box-shadow offsets and some media query breakpoints.

The CSS converter on this page leaves comments, strings and url() paths untouched, keeps 1px values by default and, unless you untick the option, does not change the numbers inside @media queries.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16px root, rem = px / 16, so 24px = 24 / 16 = 1.5rem.

How do I convert rem to px?

Multiply the rem value by the root font size. With a 16px root, 1.25rem = 1.25 x 16 = 20px.

What is the difference between rem and em?

rem is relative to the font size of the root html element, so it is the same everywhere on the page. em is relative to the font size of the element's parent (or the element itself for properties other than font-size), so nested em values compound.

Why use rem instead of px?

rem values scale when a visitor changes their browser's default font size, which makes text and spacing more accessible. px values ignore that setting for font sizes.

What is 16px in rem?

16px is 1rem when the root font size is the browser default of 16px. 14px is 0.875rem, 12px is 0.75rem and 32px is 2rem.

What does html { font-size: 62.5% } do?

It sets the root font size to 62.5% of 16px, which is 10px, so 1rem = 10px and conversions become simple: 24px = 2.4rem. Set the base to 10 in this tool to match.

Should 1px borders be converted to rem?

Usually not. Hairline borders are often kept at 1px so they stay crisp at every zoom level. The CSS converter keeps 1px values by default; untick the option to convert them too.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CSS FormatterBeautify CSS with indent controls and optional property sorting.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.Unit ConverterConvert length, weight, volume, temperature and more.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.Font Size ConverterConvert font sizes between px, pt, em, rem, % and vw, with a 6–72px chart and CSS.Golden Ratio CalculatorSplit a length into golden sections, find a from b, and get a φ scale of design sizes.PT to PXConvert points to pixels (pt to px) instantly, with formula and chart.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Tooltip GeneratorBuild pure CSS tooltips: position, arrow, colors, padding and animation. Copy HTML and CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.
See all 52 Web, HTML & CSS Tools →