๐ Runs in your browser โ nothing is uploadedโ Free, no signup
PX to REM Converter
Convert pixels to rem and rem to pixels for any root font size โ or paste a stylesheet to convert every px value at once.
24px = 1.5rem when the root font size is 16px.
Convert a stylesheet
Result
.card {
padding: 1.5rem 2rem;
font-size: 0.875rem;
border: 1px solid #ddd;
margin-bottom: 0;
}Conversion table (16px root)
When should you use the PX to REM Converter?
- Turning pixel values from a design file into accessible rem units
- Migrating an existing stylesheet from px to rem
- Checking what a rem value equals in pixels
How to use the PX to REM Converter
- 1
Set the root font size
Leave it at 16px (the browser default) or enter your site's html font size.
- 2
Convert a single value
Type in the px box to get rem, or in the rem box to get px.
- 3
Convert a whole stylesheet
Paste CSS into 'Convert a stylesheet'. Every px value is replaced with rem.
- 4
Copy the result
Click Copy CSS to copy the converted stylesheet.
Examples
Converting CSS (16px root)
Before
.card {
padding: 24px 32px;
font-size: 14px;
border: 1px solid #ddd;
}After
.card {
padding: 1.5rem 2rem;
font-size: 0.875rem;
border: 1px solid #ddd;
}Common errors and how to fix them
Converted sizes look wrong on my site- Your site may change the root font size (for example html { font-size: 62.5% } makes 1rem = 10px). Set Root font size to match.
Media queries behave differently after converting- In media queries, rem and em are always based on the browser's default font size, not your html font-size rule.
More from Design & Color
Free tools that run in your browser โ no signup, nothing uploaded.
Color Picker & Converter
Pick a color and convert between HEX, RGB and HSL instantly.
Color Palette Generator
Generate harmonious color palettes and export them as CSS, Tailwind or JSON.
CSS Gradient Generator
Build linear and radial CSS gradients visually and copy the code.
CSS Box Shadow Generator
Design layered CSS box shadows visually and copy the CSS or Tailwind class.
CSS Border Radius & Blob Generator
Set rounded corners per side or make organic blob shapes, then copy the CSS.
Glassmorphism CSS Generator
Create frosted-glass UI cards with backdrop blur and copy the CSS.
CSS Clamp() Fluid Size Calculator
Generate clamp() values for fluid typography and spacing between two screen sizes.
CSS Text Shadow Generator
Build CSS text shadows โ soft, neon, outline or retro โ and copy the code.
JSON Auto-Fixer & Formatter
Repair, validate, and beautify broken JSON (missing quotes, trailing commas).
PX to REM Converter FAQ
Divide the pixel value by the root font size. With the default root size of 16px, 24px รท 16 = 1.5rem. To go back, multiply: 1.5rem ร 16 = 24px.
It's the font size of the <html> element. Browsers default to 16px, but users can change it in their settings, and some sites set html { font-size: 62.5% } to make 1rem = 10px. Enter your site's value to convert correctly.
rem units scale with the user's browser font-size setting, so text and spacing grow for people who need larger text. That makes layouts more accessible than fixed pixels.
rem is relative to the root (<html>) font size everywhere on the page. em is relative to the font size of the current element, so it compounds when elements are nested.
Usually not. Hairline borders are meant to stay 1px at any text size, which is why the stylesheet converter keeps values of 1px or less by default. Untick the option to convert them too.
Yes. Paste CSS into 'Convert a stylesheet' and every px value is replaced with its rem equivalent. 0px becomes 0.
