PX to REM Converter for Tailwind CSS Attachments

Tailwind's spacing scale is built on rem — convert any pixel value to the rem value (and Tailwind class) it maps to, free, no signup.

Convert px to rem now — free →

Free · No signup · No watermark · Private

Why Tailwind CSS uses rem

Tailwind's spacing and typography scale is built on rem, not pixels. One rem equals the font size of the root (html) element, which browsers default to 16px. That is why Tailwind classes map so cleanly: the class name is just the rem value multiplied by 4.

The practical payoff is accessibility. When a user raises their browser's default text size, every rem-based space and font size scales with it. Pixel values do not — a 16px margin stays 16px no matter what the user needs.

The formula (and the table you actually need)

The conversion is one division: rem = px ÷ root font size. At the standard 16px root:

  • 4px = 0.25rem — Tailwind p-1
  • 8px = 0.5rem — Tailwind p-2
  • 12px = 0.75rem — Tailwind p-3
  • 16px = 1rem — Tailwind p-4
  • 24px = 1.5rem — Tailwind p-6
  • 32px = 2rem — Tailwind p-8
  • 48px = 3rem — Tailwind p-12
  • 64px = 4rem — Tailwind p-16

Notice the pattern: the Tailwind number is the rem value times 4. So a design spec that says "32px of padding" is p-8, and "20px" (1.25rem) is p-5.

Convert px to rem for Tailwind — step by step

  1. Open the free PX to REM Converter.
  2. Type the pixel value from your design — values like 14, 24.5 or 320 all work.
  3. Leave the root font size at 16px unless your project changes it. If your html font size is different, set that value instead so the result matches your site.
  4. Copy the rem value and use it in your CSS — or divide by 4 in reverse to find the Tailwind class (2rem × 4 = p-8).

Everything runs in your browser: no signup, nothing uploaded, and the result is ready to paste.

When to keep px anyway

Rem is the right default for spacing and type, but px still has a job. Borders, hairline dividers, box shadows and fixed-size icons should stay in px — scaling a 1px border to 1.25px looks wrong, and a 1px line is a deliberate visual detail, not a layout size. Most production stylesheets use both: rem for the layout, px for the fine details.

Frequently asked questions

How do I convert px to rem for Tailwind CSS?

Divide the pixel value by your root font size. With the default 16px root, 16px = 1rem, 24px = 1.5rem and 32px = 2rem. Open the PX to REM Converter, type the pixel value, and it does the division for you.

What is Tailwind's spacing scale in px and rem?

Tailwind's default spacing scale steps by 0.25rem, which is 4px at a 16px root: p-1 = 0.25rem (4px), p-2 = 0.5rem (8px), p-4 = 1rem (16px), p-8 = 2rem (32px) and p-16 = 4rem (64px).

What is 1rem in px?

1rem equals the root font size, which browsers default to 16px. So 1rem = 16px unless your project changes the font size on the html element.

Does the converter work if my project uses a different root font size?

Yes. Set the root font size in the converter to match your project (for example 10px or 20px) and every result is recalculated against that base.

Can the tool convert rem back to px?

No — this tool converts px to rem only. To go the other way, multiply the rem value by your root font size: 2.5rem at a 16px root is 40px.

Should everything in CSS be rem instead of px?

Not everything. Use rem for font sizes, padding, margins and layout spacing so the design scales with the user's text size. Keep px for details that must never scale, such as 1px borders and hairline dividers.

The short version

Tailwind's scale is rem-based at a 16px root, so divide any pixel value by 16 — or let the PX to REM Converter do it, especially when your project uses a custom root size. Then multiply the rem value by 4 to find the Tailwind class.

Related tools