PX to REM Converter
Convert px, rem, em, pt, vw and more, generate fluid clamp() font sizes and rewrite whole stylesheets to rem.
About this tool
Designs are usually measured in pixels, but CSS works best in relative units. rem is relative to the root font size (16px in every browser by default), so 1.5rem equals 24px until the user raises the default font size in their browser settings, at which point everything sized in rem grows with it. em is relative to the parent element’s font size, and vw and vh are percentages of the viewport. Using rem for type and spacing respects user preferences and is required for good accessibility.
This converter turns any length into all common CSS units at once with your own root size, parent size and viewport. It also does three jobs that come up every day in front-end work: it generates fluid font sizes with clamp() that grow smoothly between two screen widths, rewrites every px value in a pasted stylesheet to rem while leaving 1px borders and media queries alone, and builds a modular type scale as CSS variables.
How to use PX to REM Converter
- Set the root font size if your project changes it (for example 10px with html { font-size: 62.5%; }).
- Type a value and pick its unit: every other unit updates instantly. Click a row in the common sizes table to load it.
- For responsive type, open Fluid clamp(), enter the smallest and largest size and the viewport range, and check the preview at any width.
- To convert a stylesheet, open CSS px → rem, paste the CSS and copy the result.
Examples
Pixels to rem
24px with a 16px root
1.5rem (also 1.5em, 18pt, 1.6667vw at 1440px)
Fluid heading
16px at 375px → 24px at 1280px
font-size: clamp(1rem, 0.7928rem + 0.884vw, 1.5rem);
Below 375px the size stays at 1rem and above 1280px it stays at 1.5rem; in between it grows linearly.
Bulk conversion
.btn { padding: 12px 24px; border: 1px solid; } .btn { padding: 0.75rem 1.5rem; border: 1px solid; } Which unit to use where
- rem for font sizes, spacing and layout widths that should follow the user’s font preference. This is the safest default.
- em for values that should scale with the component’s own text, such as padding inside a button or the size of an icon next to text.
- px for hairlines and details that must not scale, such as 1px borders, and for box shadows.
- vw and vh for full-screen sections and fluid values, but never alone for font sizes: text sized only in vw ignores zoom, which fails WCAG 1.4.4. Combine vw with rem in clamp().
- % is relative to the parent: for widths it uses the parent’s width, for font-size the parent’s font size.
How the clamp() formula works
clamp(min, preferred, max) picks the preferred value but never goes below min or above max. For fluid type the preferred value is a straight line: slope = (max size − min size) ÷ (max viewport − min viewport), and the intercept is min size − slope × min viewport. The tool writes the slope in vw (slope × 100) and the intercept in rem, so the result still responds to browser zoom and font settings.
Keep the ratio between the largest and smallest size moderate, around 1.5 to 2.5 for headings. Very steep slopes make text jump in size when a window is resized, and WCAG requires that text can be zoomed to 200%; with a rem intercept that remains possible.
Frequently asked questions
Everything you need to know about this tool and data security.
Is the root font size always 16px?
It is the default in all major browsers, but users can change it, and some projects set html { font-size: 62.5% } to make 1rem equal 10px. Enter your real root size in the tool so the conversions match your CSS.
Should media queries use px, em or rem?
In media queries em and rem are always based on the browser default font size, not on your html font-size. Many teams keep px for breakpoints because they match design tools; em-based breakpoints have the advantage of reacting to the user’s font size. The bulk converter leaves media queries in px by default.
Why are 1px borders not converted?
A border of 0.0625rem can render as a blurry or missing line on some screens, and borders usually should not grow with text. Values below the “Keep values below” threshold stay in px; set it to 0 to convert everything.
Is my data safe when using this tool?
Yes, 100% safe. This tool operates entirely inside your web browser using client-side JavaScript and WebAssembly. Your data never touches any external server.
Related Tools
Try every flexbox and CSS grid property on live boxes and copy the CSS or Tailwind classes.
Convert length, weight, temperature, area, volume, speed, data size and time between metric, US, imperial and traditional units.
Minify or beautify HTML, CSS and JavaScript and see how many bytes you save.
Featured Projects tech-fun.net
Explore more AI & productivity tools
Nihongo GameBox
Master Japanese typing, Kana, and JLPT N5–N1 vocabulary through interactive retro arcade games.
ResumeGPT
Tailors CVs and cover letters to every job opportunity with a multi-agent LLM pipeline, job tracking, and scheduled discovery.
CollectMind
Turns your bookmarks into a searchable AI knowledge base — entirely on-device, powered by Chrome's built-in Gemini Nano.