WebToolsHub Logo
WebToolsHubOnline Tool Suite

PX to REM Converter

Type any px value and get the rem equivalent instantly or flip it around and go rem → px. The base font size defaults to 16px but you can change it to match your project. Everything runs in your browser; nothing leaves your machine.

What Is a PX to REM Converter?

A px to rem converter is a tool that turns pixel values into rem units for CSS and back again. If you've ever been staring at a Figma design that says 24px and needed to write font-size: 1.5rem; in your stylesheet without doing the division in your head, this is exactly what you need.

The px to rem formula is dead simple:

rem = px ÷ base font size
px  = rem × base font size

With the browser default of 16px, that means 24px ÷ 16 = 1.5rem. Change your project's root font size to 10px (a common trick in older codebases) and the math shifts entirely. This tool handles all of that automatically just update the base and every value recalculates in real time.

I built this because mental math mid-coding session is a terrible use of brain cells. Sound familiar? You're deep in a component, you need six different spacing values all in rem, and you're context-switching to a calculator app every 90 seconds. This tool kills that loop.

How to Use the PX to REM Converter

  1. Choose your direction: Toggle between PX → REM or REM → PX using the buttons at the top. Hit the swap icon (↔) to flip direction instantly your current result becomes the new input automatically.

  2. Set your base font size: The default is 16px which matches every major browser's default. If your project uses html { font-size: 10px; } or any custom root size, update this field and all values recalculate immediately.

  3. Type your value: Enter any number in the input field. Results appear instantly as you type no button to press, no page reload.

  4. Copy your CSS: Below the result you'll see a ready-to-paste CSS snippet like font-size: 1.5rem; /* 24px */ plus a Tailwind arbitrary value line. Hit the copy button and it's in your clipboard.

  5. Use Quick-Copy Property Cards: Four cards appear with your result applied to font-size, margin, padding, and gap. Click any card to copy that specific snippet.

  6. Bulk convert: Expand the Bulk Converter section to convert multiple values at once. Add as many rows as you need, then hit "Copy All" to grab the full list perfect for converting an entire spacing scale or type ramp in one shot.

Key Features

  • Bidirectional conversion: PX to REM and REM to PX in the same tool. No juggling between two separate pages. The swap button makes chain conversions effortless verify your math by going back and forth in one click.

  • Custom base font size: Change the root font size to match your actual project. Supports any number 10px, 14px, 18px, whatever your <html> element declares. Reset button brings it back to 16px in one click.

  • Instant / real-time results: No submit button. Results update on every keystroke using React state zero delay.

  • CSS snippet output: Generates a copy-ready snippet in standard CSS format with a comment showing the original value, plus a Tailwind arbitrary-value equivalent like text-[1.5rem].

  • Quick-copy property cards: One-click copy for four common CSS properties font-size, margin, padding, and gap using your converted value. Cards flash green on copy.

  • Bulk converter: Convert an entire list of values at once. Add unlimited rows, delete what you don't need, and export everything with "Copy All". Direction and base changes update every row instantly.

  • Reference table (1–100px): A scrollable table covering every whole-pixel value from 1px to 100px, organized in three ranges. Each row has a copy button for its CSS snippet. The table recalculates dynamically when you change the base.

  • 100% client-side processing: Everything runs in your browser using JavaScript. No API calls, no server, no data logging. Your values never leave your device.

When Should You Use This Tool?

If you're doing any kind of responsive web development in 2026, you're probably using rem units for font sizes and spacing. The question isn't whether to use rem it's how to convert quickly without breaking flow.

Translating Figma designs to code: Design tools output pixel values. Your CSS should use rem. This is the gap this tool bridges. Paste the value, get the rem, move on.

Building a type scale or spacing system: If you're defining a design system say, spacing tokens at 4, 8, 12, 16, 24, 32, 48, 64px throw them all into the bulk converter and export the full rem scale in one shot. No manual math, no errors.

Working with a non-standard base font size: Some older projects set html { font-size: 62.5%; } to make 1rem = 10px. If you're working on one of those codebases and your team's new to it, the default 16px converter will give you wrong answers. This tool lets you set any base problem solved. You might also find our CSS to Tailwind converter useful when you're porting pixel-based legacy CSS into a Tailwind project.

Accessibility auditing: Using rem for font sizes means users who increase their browser's default font size actually see larger text. Using px overrides that preference. If you're auditing a codebase for WCAG compliance and replacing hardcoded pixel values, this tool helps you batch-convert in seconds.

PX vs REM vs EM - What's Actually the Difference?

This trips up a lot of developers early on. Here's a clear breakdown:

  • px (Pixels): An absolute unit. font-size: 16px is always exactly 16 pixels regardless of any browser settings. It's predictable and precise, which is why designers love it. The problem: it ignores the user's browser font size preference. A user who sets their browser to "Large" text because of low vision gets no benefit from your px-based font sizes.

  • rem (Root Em): A relative unit based on the font-size of the <html> element. By default, browsers set this to 16px, so 1rem = 16px. If a user changes their browser's base font size to 20px, then 1rem = 20px on their device your layout scales with them. This is what makes rem the right choice for accessible, responsive typography.

  • em (Em): Also relative, but based on the font size of the parent element, not the root. This creates compounding: a 1.2em element inside another 1.2em element renders at 1.44em relative to root. Useful for scaling components internally, but can cause unexpected results in deeply nested layouts. rem avoids this entirely because it always refers back to the root.

The MDN Web Docs has a thorough reference on CSS values and units if you want to go deeper into the spec. For practical usage, the rule of thumb most teams follow: use rem for font sizes and spacing, use px only for things that should never scale like a 1px border or a 24px icon.

Understanding the PX to REM Formula

The math behind the conversion is one line:

rem = px ÷ base font size

With a standard 16px base:

  • 16px ÷ 16 = 1rem

  • 24px ÷ 16 = 1.5rem

  • 32px ÷ 16 = 2rem

  • 12px ÷ 16 = 0.75rem

  • 48px ÷ 16 = 3rem

Going the other way (REM → PX):

px = rem × base font size
  • 1.5rem × 16 = 24px

  • 0.875rem × 16 = 14px

  • 2.25rem × 16 = 36px

If your project uses html { font-size: 10px; } a pattern used to make the math "easier" (10px = 1rem, 1.6rem = 16px) just set the base to 10 in the tool and all conversions adjust automatically.

This "10px trick" was popular in the early 2010s but is now considered an anti-pattern because it overrides the user's browser font preference before anything else can respond to it. Modern best practice is to leave the <html> font size alone (or set it as a percentage like 100%) and let 1rem = user's preference. The WCAG 2.2 success criterion 1.4.4 (Resize Text) specifically calls out this issue.

Using REM with Tailwind CSS

Tailwind's spacing and typography scale already uses rem internally. text-base is 1rem (16px), text-xl is 1.25rem (20px), and so on. But when you're working with custom values from a design spec that don't hit Tailwind's preset scale, you need arbitrary values:

<p class="text-[1.375rem] mt-[2.5rem]">Custom sized text</p>

This tool generates those Tailwind arbitrary value strings automatically alongside the standard CSS output. If you're building a custom design system on top of Tailwind and want to define CSS variables for your spacing tokens, our shadcn theme generator pairs well with this workflow it handles the CSS variable layer that maps your rem tokens into a cohesive theme.

A note on Tailwind v4: the new version (released in early 2025) uses a CSS-first config approach and accepts rem values directly in @theme blocks. If you're on v4, converting your design tokens to rem before adding them to your theme config is exactly the workflow this tool supports. See the Tailwind v4 migration guide for a full walkthrough of what changed.

Common Mistakes to Avoid

  • Using the wrong base font size: The most common mistake. If your project sets a custom root font size (even through a percentage like 62.5%), and you use this tool with the default 16px base, every conversion will be wrong. Always check your <html> or :root font-size first.

  • Using px for font sizes on accessible projects: It's 2026 there's really no excuse for font-size in pixels on public-facing sites. Users with visual impairments rely on browser font size settings. rem respects that. px overrides it. Make the switch.

  • Mixing rem and px inconsistently: It's fine to use px for borders and icon sizes, but mixing units randomly for spacing and typography creates a maintenance nightmare. Decide on a convention per property type and stick to it across the codebase.

  • Forgetting that em compounds: If you're using em instead of rem for spacing inside components, remember that nesting multiplies the values. A padding: 1em inside a font-size: 1.25em parent is not the same as 1rem. Use this tool's conversion for rem, and switch to em only where the compounding is intentional.

  • Not using the bulk converter for full scales: If you're converting more than two or three values, the single converter is slower than it needs to be. The bulk converter handles unlimited rows in one go. Use it for your full type scale or spacing system you'll save 5 minutes of back-and-forth every time.

Developer Workflow Integration

Here's how this tool fits into a real frontend development workflow. Say you're building a Next.js app with a custom design system. Your designer hands you a Figma file with these type sizes defined in pixels: 12, 14, 16, 18, 20, 24, 30, 36, 48, 60, 72.

You open the bulk converter, add all 11 values, and hit "Copy All". You get:

12px = 0.75rem
14px = 0.875rem
16px = 1rem
18px = 1.125rem
20px = 1.25rem
24px = 1.5rem
30px = 1.875rem
36px = 2.25rem
48px = 3rem
60px = 3.75rem
72px = 4.5rem

Those values go directly into your Tailwind config or CSS custom properties. The whole operation took under 30 seconds. Compare that to a spreadsheet or manual calculation there's no comparison.

For teams using CSS custom properties for design tokens, you can also check out the W3C's CSS Custom Properties specification for how tokens are recommended to be defined at the root level and our own CSS variables and design tokens guide for how to wire them up with dark mode support in a real Next.js app.

Related Tools You Might Find Useful

If you're working on responsive CSS and design systems, these tools pair naturally with the px to rem converter:

  • CSS to Tailwind Converter: paste standard CSS and get Tailwind class equivalents. Useful when migrating a pixel-heavy legacy stylesheet into a Tailwind project.

  • shadcn Theme Generator: generate a complete shadcn/ui color theme with CSS custom properties. Once you've converted your spacing tokens to rem, this tool handles the color layer of your design system.

  • HTML to JSX/TSX Converter: convert standard HTML snippets to valid JSX. Useful when moving Figma-to-HTML code into a React component, right after fixing your units with this converter.

  • Tailwind SVG Background Generator: create SVG-based background patterns as Tailwind-compatible CSS. Great for adding visual texture to components while staying in the Tailwind workflow.

Real-World Examples: Converting Common Design Values

Here are the most common pixel values you'll encounter in real projects, converted to rem at the standard 16px base. Bookmark this if nothing else.

  • Typography: 12px = 0.75rem (small/caption text), 14px = 0.875rem (body small), 16px = 1rem (body default), 18px = 1.125rem (body large), 20px = 1.25rem (lead text), 24px = 1.5rem (h4), 30px = 1.875rem (h3), 36px = 2.25rem (h2), 48px = 3rem (h1)

  • Spacing (4px grid): 4px = 0.25rem, 8px = 0.5rem, 12px = 0.75rem, 16px = 1rem, 24px = 1.5rem, 32px = 2rem, 48px = 3rem, 64px = 4rem, 80px = 5rem, 96px = 6rem

  • Layout: 320px = 20rem (mobile min-width), 768px = 48rem (tablet breakpoint), 1024px = 64rem (desktop sm), 1280px = 80rem (desktop md), 1440px = 90rem (desktop lg)

Notice those breakpoint values? That's one of the most underused applications of this converter. CSS media queries accept rem values, and using them means your breakpoints also scale with the user's font preference something pixel-based media queries can't do. Ever had a layout break for a user who'd bumped their browser font size? rem-based breakpoints fix that.

/* Pixel-based — doesn't scale */
@media (min-width: 768px) { ... }

/* Rem-based — scales with user preference */
@media (min-width: 48rem) { ... }

The Core Web Vitals optimization guide covers this in more depth responsive text sizing directly affects CLS (Cumulative Layout Shift) scores, which is a Google ranking factor.

Integrating REM Conversions into Your CSS Workflow

Beyond one-off conversions, there are a few workflow patterns worth knowing if you're committing to rem-first development.

CSS custom properties for your token system: Once you've converted your design tokens to rem, define them as custom properties at the :root level:

:root {
  --space-1:  0.25rem;  /* 4px  */
  --space-2:  0.5rem;   /* 8px  */
  --space-4:  1rem;     /* 16px */
  --space-8:  2rem;     /* 32px */
  --space-16: 4rem;     /* 64px */

  --text-sm:   0.875rem; /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg:   1.125rem; /* 18px */
  --text-xl:   1.25rem;  /* 20px */
  --text-2xl:  1.5rem;   /* 24px */
  --text-4xl:  2.25rem;  /* 36px */
}

This pattern is used in every major design system Material Design, Fluent, and shadcn/ui all define their spacing and type tokens as CSS custom properties at root. Once it's wired up, changing the root font size cascades through the entire token system automatically.

PostCSS and build-time conversion: If you're working on a large legacy codebase with thousands of px declarations, there's a PostCSS plugin called postcss-pxtorem that automates the conversion at build time. You write in pixels during development, the plugin converts to rem in the output CSS. It uses the same formula this tool uses. Useful as a migration bridge not as a long-term architecture.

Sass functions: If you're using Sass, a common pattern is a conversion function you can call inline:

@function rem($px, $base: 16) {
  @return #{$px / $base}rem;
}

h1 { font-size: rem(36); }    // → 2.25rem
p  { font-size: rem(16); }    // → 1rem
.card { padding: rem(24); }   // → 1.5rem

Whether you use a Sass function, PostCSS plugin, or this converter manually the underlying math is identical. The tool is just the fastest path when you need a quick answer during active development.

Why Use WebToolsHub?

Every tool on WebToolsHub is completely free, requires no account, and processes everything client-side in your browser. There are no usage limits, no API keys to manage, and your data never reaches any server. The px to rem converter like all tools here is built specifically for developer productivity: fast to load, distraction-free, and focused on doing one thing well.

No ads mid-workflow, no email gates, no "upgrade to unlock bulk" paywalls. Just open it, use it, close it. That's the entire philosophy.

Frequently Asked Questions

Is this PX to REM converter free to use?

Yes, completely free. No account required, no signup, no usage limits, and no premium tier. Open the tool and use it that's it.

Does this tool store or send my data anywhere?

No. All conversion logic runs entirely in your browser using client-side JavaScript. Your pixel values and results are never transmitted to any server, stored in a database, or logged anywhere. Once you close the tab, nothing is retained.

What is the px to rem formula?

The formula is: rem = px ÷ base font size. With the default browser base of 16px, 24px ÷ 16 = 1.5rem. Going the other way: px = rem × base font size, so 1.5rem × 16 = 24px. Change the base font size in the tool if your project uses a non-standard root font size.

What is 1px in rem with a 16px base?

With a standard 16px base font size, 1px = 0.0625rem. You can verify: 1 ÷ 16 = 0.0625. Similarly, 16px = 1rem, 24px = 1.5rem, and 32px = 2rem. If your project uses a 10px base, then 1px = 0.1rem.

What is the difference between rem and em in CSS?

rem (Root Em) is always relative to the <html> element's font size typically 16px by default. It's consistent anywhere on the page. em is relative to the font size of the current parent element, which means it compounds through nested elements. For example, a 1.2em element inside another 1.2em element renders at 1.44em relative to root. For spacing and font sizes across a layout, rem is almost always the safer, more predictable choice.

How does the custom base font size option work?

The base font size field controls what 1rem equals in your project. The default is 16px because that's what all major browsers use by default. If your stylesheet sets html { font-size: 10px; } or html { font-size: 62.5%; }, change the base to 10 and all conversions will reflect that. The converter, bulk table, and reference table all update instantly when you change the base no need to re-enter values.

Can I convert multiple px values at once?

Yes. Expand the Bulk Converter section, add as many rows as you need, and enter your values. All rows calculate simultaneously. Hit 'Copy All' to export the full list as formatted output useful for converting an entire spacing scale or type ramp in one go. Direction and base font size changes apply to all rows at the same time.

How do I convert px to rem for Tailwind CSS?

Tailwind uses rem internally for its preset scale. For custom values not in Tailwind's scale, you use arbitrary values like text-[1.5rem] or mt-[2.5rem]. This tool generates the Tailwind arbitrary value string automatically alongside the standard CSS snippet. Just convert your px value, and the Tailwind line is ready to copy.

Why should I use rem instead of px for font sizes?

Using rem for font sizes respects the user's browser font size preference. If a user sets their browser to display larger text (common for people with visual impairments), rem-based sizes scale with that setting. Pixel-based font sizes ignore it entirely. WCAG 2.2 success criterion 1.4.4 (Resize Text) specifically requires that text can be resized without assistive technology up to 200% without loss of content. Using rem is the simplest way to satisfy this.

What browsers does this tool support?

All modern browsers Chrome, Firefox, Safari, and Edge. No plugins or extensions required. The tool uses standard browser APIs and React for real-time state updates, both of which are universally supported in any browser released in the last several years.